shithub: MicroHs

Download patch

ref: d6b4582c446dcf11d271c27b502c92abdc8f27fe
parent: dde9ba0486a5f166815c02eb9e9ebbe6b9fa5cda
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Fri Sep 22 12:16:28 EDT 2023

Add words

--- a/lib/Text/String.hs
+++ b/lib/Text/String.hs
@@ -92,6 +92,14 @@
 unlines :: [String] -> String
 unlines = concatMap (++ "\n")
 
+
+words :: String -> [String]
+words s =
+  case dropWhile isSpace s of
+    "" -> []
+    s' -> w : words s''
+      where (w, s'') = span (not . isSpace) s'
+
 unwords :: [String] -> String
 unwords ss = intercalate " " ss
 
--