on master help sign in
added word-function as in haskell in prelude.string.
commit20fc41c5ff33c6ed0503ed44a460f7af6e957acd authorMekeor Melire <mekeor@ymail.com> dateMon 9 Apr 2012, 23:17 (15 years ago) parentb90c3b4
1 file changed+8
lib/prelude/strings.idr+8
lib/prelude/strings.idr+8
@@ -62,3 +62,11 @@ ltrim xs with (strM xs)
6262trim : String -> String
6363trim xs = ltrim (reverse (ltrim (reverse xs)))
6464
65+words' : List Char -> List (List Char)
66+words' s = case dropWhile isSpace s of
67+ [] => []
68+ s' => let (w, s'') = break isSpace s'
69+ in w :: words' s''
70+
71+words : String -> List String
72+words s = map pack $ words' $ unpack s