on master help sign in
Add isNL/lines
44dd3beEdwin Brady
lib/Prelude/Chars.idr+3
@@ -22,6 +22,9 @@ isSpace x = x == ' ' || x == '\t' || x == '\r' ||
22 x == '\n' || x == '\f' || x == '\v' ||
22 x == '\n' || x == '\f' || x == '\v' ||
23 x == '\xa0'
23 x == '\xa0'
24
24
25+isNL : Char -> Bool
26+isNL x = x == '\r' || x == '\n'
27+
25toUpper : Char -> Char
28toUpper : Char -> Char
26toUpper x = if (isLower x)
29toUpper x = if (isLower x)
27 then (prim__intToChar (prim__charToInt x - 32))
30 then (prim__intToChar (prim__charToInt x - 32))
lib/Prelude/Strings.idr+9
@@ -74,6 +74,15 @@ words' s = case dropWhile isSpace s of
74words : String -> List String
74words : String -> List String
75words s = map pack $ words' $ unpack s
75words s = map pack $ words' $ unpack s
76
76
77+lines' : List Char -> List (List Char)
78+lines' s = case dropWhile isNL s of
79+ [] => []
80+ s' => let (w, s'') = break isSpace s'
81+ in w :: words' s''
82+
83+lines : String -> List String
84+lines s = map pack $ words' $ unpack s
85+
77partial
86partial
78foldr1 : (a -> a -> a) -> List a -> a
87foldr1 : (a -> a -> a) -> List a -> a
79foldr1 f [x] = x
88foldr1 f [x] = x