From de191b2614db104b4cd02d53a05c8896b10c4c90 Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Thu, 21 Sep 2017 15:25:25 +0300 Subject: [PATCH] Improve joinWithSeparator and intercalate documentation refs #7490 Change-Id: Iaf856a02d806b4f1bcdc0b56c5724fbcd620dbca --- bundles/org.simantics.scl.runtime/scl/Prelude.scl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bundles/org.simantics.scl.runtime/scl/Prelude.scl b/bundles/org.simantics.scl.runtime/scl/Prelude.scl index f2c242765..77e62c858 100644 --- a/bundles/org.simantics.scl.runtime/scl/Prelude.scl +++ b/bundles/org.simantics.scl.runtime/scl/Prelude.scl @@ -1563,12 +1563,25 @@ printWithSeparator sb sep l = loop 0 (if i==0 then sb else sb << sep) <+ l!i loop (i+1) -"Joins the string representations of the list of values with the given separator." +""" +Joins the string representations of the list of values with the given separator. + +See [intercalate](#intercalate) for an alternative that works with Strings +and doesn't escape its arguments. +""" joinWithSeparator :: Show a => String -> [a] -> String joinWithSeparator separator values = runProc ( StringBuilder.toString $ printWithSeparator StringBuilder.new separator values) +""" +The intercalate function takes a String and a list of Strings +and concatenates the list after interspersing the first argument +between each element of the list. + +See also more generic [joinWithSeparator](#joinWithSeparator) +which escapes its arguments using `show`. +""" intercalate :: String -> [String] -> String intercalate separator strings = do l = length strings -- 2.43.2