]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.runtime/scl/Prelude.scl
Add undocumented functions in Prelude.scl to Prelude.md
[simantics/platform.git] / bundles / org.simantics.scl.runtime / scl / Prelude.scl
index 83d84ccf2da505c6590b404c23c93a484fb98ad2..f2c24276510635390abee532e46f960547e381e9 100644 (file)
@@ -123,6 +123,7 @@ uncurry3 f (x, y, z) = f x y z
 flip :: (a -> b -> <e> c) -> b -> a -> <e> c
 flip f x y =  f y x
 
+"Swaps the order of elements of a pair (2-tuple)."
 swap :: (a,b) -> (b,a)
 swap (x,y) = (y,x)
 
@@ -1417,6 +1418,17 @@ instance Read String where
 splitString :: String -> String -> [String]
 splitString source pattern = arrayToList $ splitString_ source pattern
 
+"""
+`split pattern text` splits `text` around matches of the given regular expression `pattern`.
+
+This function works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array.
+
+The string "boo:and:foo", for example, yields the following results with these expressions:
+
+    Regex   Result
+    :       { "boo", "and", "foo" }
+    o       { "b", "", ":and:f" }
+"""
 split :: String -> String -> [String]
 split pattern text = arrayToList $ splitString_ text pattern