X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.runtime%2Fscl%2FPrelude.scl;h=f2c24276510635390abee532e46f960547e381e9;hb=refs%2Fchanges%2F91%2F991%2F4;hp=83d84ccf2da505c6590b404c23c93a484fb98ad2;hpb=7db6413ad1d17e7ce4fea3a64f5de435039ad9a6;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.runtime/scl/Prelude.scl b/bundles/org.simantics.scl.runtime/scl/Prelude.scl index 83d84ccf2..f2c242765 100644 --- a/bundles/org.simantics.scl.runtime/scl/Prelude.scl +++ b/bundles/org.simantics.scl.runtime/scl/Prelude.scl @@ -123,6 +123,7 @@ uncurry3 f (x, y, z) = f x y z flip :: (a -> b -> c) -> b -> a -> 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