X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.runtime%2Fscl%2FPrelude.scl;h=eb1e8cd6ff35bed0186d22d68e7b115626246d04;hp=c81f8308954e8ee241653b686b8d0bcbeffdaa6c;hb=9fafa930ec59d0001415f5cff3579456ec38ae65;hpb=f9e11892b65f0bcc1b9e5967101888568eb1f264 diff --git a/bundles/org.simantics.scl.runtime/scl/Prelude.scl b/bundles/org.simantics.scl.runtime/scl/Prelude.scl index c81f83089..eb1e8cd6f 100644 --- a/bundles/org.simantics.scl.runtime/scl/Prelude.scl +++ b/bundles/org.simantics.scl.runtime/scl/Prelude.scl @@ -1540,6 +1540,24 @@ joinWithSeparator :: Show a => String -> [a] -> String joinWithSeparator separator values = runProc ( StringBuilder.toString $ printWithSeparator StringBuilder.new separator values) + +intercalate :: String -> [String] -> String +intercalate separator strings = do + l = length strings + if l == 0 + then "" + else if l == 1 + then strings!0 + else runProc do + sb = StringBuilder.new + sb << strings!0 + loop i | i == l = () + | otherwise = do + sb << separator << strings!i + loop (i+1) + loop 1 + StringBuilder.toString sb + instance (Show a) => Show [a] where sb <+ l = do len = length l