Verified Commit 8866fbcd authored by Camil Staps's avatar Camil Staps 🚀

Add Text.Language

parent c28cd6c8
Pipeline #8767 passed with stage
in 1 minute and 41 seconds
definition module Text.Language
:: Language = English
isVowel :: Language Char -> Bool
isConsonant :: Language Char -> Bool
pluralise :: Language String -> String
pluralisen :: Language Int String -> String
implementation module Text.Language
import StdArray
import StdBool
from StdFunc import id
import StdList
import StdString
import Text
isVowel :: Language Char -> Bool
isVowel English c = isMember c ['aeiou']
isConsonant :: Language Char -> Bool
isConsonant l c = not (isVowel l c)
pluralise :: Language String -> String
pluralise English s
| last == 'y' && (isConsonant English forelast || forelast == 'u')
= s % (0, size s-2) +++ "ies"
= s +++ "s"
where (last, forelast) = (s.[size s-1], s.[size s-2])
pluralisen :: Language Int String -> String
pluralisen English n s = n <+ " " <+ if (n == 1) id (pluralise English) s
...@@ -132,6 +132,7 @@ import qualified Text.Encodings.MIME ...@@ -132,6 +132,7 @@ import qualified Text.Encodings.MIME
import qualified Text.Encodings.UrlEncoding import qualified Text.Encodings.UrlEncoding
import qualified Text.HTML import qualified Text.HTML
import qualified Text.JSON import qualified Text.JSON
import qualified Text.Language
import qualified Text.LaTeX import qualified Text.LaTeX
import qualified Text.PPrint import qualified Text.PPrint
import qualified Text.Parsers.CParsers.ParserCombinators import qualified Text.Parsers.CParsers.ParserCombinators
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment