on master help sign in
Merge pull request #858 from david-christiansen/string-upper-csae

Add toUpper and toLower functions for String

commitf4466979d5d1d9e35439cadea992f4b04cf2d2a5 authorEdwin Brady <edwin.brady@gmail.com> dateThu 6 Feb 2014, 15:11 (13 years ago) parentdc72d9ea4038a3
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+