on master help sign in
Add toUpper and toLower functions for String
commita4038a3f80ce1d9bcf064974155011a11e498d91 authorDavid Raymond Christiansen <david@davidchristiansen.dk> dateThu 6 Feb 2014, 00:17 (13 years ago) parent138d35e
1 file changed+13
libs/prelude/Prelude/Strings.idr+13
libs/prelude/Prelude/Strings.idr+13
@@ -145,3 +145,16 @@ unwords = pack . unwords' . map unpack
145145
146146length : String -> Nat
147147length = fromInteger . prim__zextInt_BigInt . prim_lenString
148+
149+toLower : String -> String
150+toLower x with (strM x)
151+ strToLower "" | StrNil = ""
152+ strToLower (strCons c cs) | (StrCons c cs) =
153+ strCons (toLower c) (toLower (assert_smaller (strCons c cs) cs))
154+
155+toUpper : String -> String
156+toUpper x with (strM x)
157+ strToLower "" | StrNil = ""
158+ strToLower (strCons c cs) | (StrCons c cs) =
159+ strCons (toUpper c) (toUpper (assert_smaller (strCons c cs) cs ))
160+