From 6b40915a50db3159394221a7b6b46cbb74dae606 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 16 Sep 2016 06:55:59 -0700 Subject: split-str gains ability to keep separating pieces. * eval.c (eval_init): Register split-str to split_str_keep, with optional argument. * lib.c (split_str_keep): New function, formed from split_str, with third argument. (split_str): Reduced to wrapper around split_str_keep. Thus we don't have to update umpteen existing calls with an extra nil parameter. * lib.h (split_str_keep): Declared. * txr.1: Documented new optional argument of split-str. --- txr.1 | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index e524dbce..1cbaff45 100644 --- a/txr.1 +++ b/txr.1 @@ -18436,7 +18436,7 @@ which is interposed between the catenated strings. .coNP Function @ split-str .synb -.mets (split-str < string << sep ) +.mets (split-str < string < sep <> [ keep-between ]) .syne .desc The @@ -18491,6 +18491,18 @@ This operation is nondestructive: .meta string is not modified in any way. +If the optional +.meta keep-between +argument is specified and is not +.codn nil , +If an argument is given and is true, then +.meta split-str +incorporates the matching separating pieces of +.meta string +into the resulting list, such that if the resulting +list is catenated, a string equivalent to the original +string will be produced. + Note: To split a string into pieces of length one such that an empty string produces .code nil -- cgit v1.2.3