From ecbf622ba59f6023f9b2dc73a0a5f994d8b1c27d Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 22 Jul 2020 19:57:42 -0700 Subject: New sspl function. * eval (eval_init): Register sspl, an argument-reversed interface to split-str-set. * lib.c (sspl): New function. * lib.h (sspl): Declared. * txr.1: Documented. --- eval.c | 1 + lib.c | 5 +++++ lib.h | 1 + txr.1 | 11 ++++++++++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/eval.c b/eval.c index fe11c763..2cc73d0e 100644 --- a/eval.c +++ b/eval.c @@ -6808,6 +6808,7 @@ void eval_init(void) reg_fun(intern(lit("split-str"), user_package), func_n3o(split_str_keep, 2)); reg_fun(intern(lit("spl"), user_package), func_n3o(spl, 2)); reg_fun(intern(lit("split-str-set"), user_package), func_n2(split_str_set)); + reg_fun(intern(lit("sspl"), user_package), func_n2(sspl)); reg_fun(intern(lit("tok-str"), user_package), func_n3o(tok_str, 2)); reg_fun(intern(lit("tok"), user_package), func_n3o(tok, 2)); reg_fun(intern(lit("tok-where"), user_package), func_n2(tok_where)); diff --git a/lib.c b/lib.c index 4fcd12cc..fb9b24fc 100644 --- a/lib.c +++ b/lib.c @@ -5060,6 +5060,11 @@ val split_str_set(val str, val set) return out; } +val sspl(val set, val str) +{ + return split_str_set(str, set); +} + val tok_str(val str, val tok_regex, val keep_sep) { list_collect_decl (out, iter); diff --git a/lib.h b/lib.h index fc4dfebd..f23eb36f 100644 --- a/lib.h +++ b/lib.h @@ -875,6 +875,7 @@ val split_str(val str, val sep); val split_str_keep(val str, val sep, val keep_sep); val spl(val sep, val arg1, val arg2); val split_str_set(val str, val set); +val sspl(val set, val str); val tok_str(val str, val tok_regex, val keep_sep); val tok(val tok_regex, val arg1, val arg2); val tok_where(val str, val tok_regex); diff --git a/txr.1 b/txr.1 index a2cfd4e3..23d149af 100644 --- a/txr.1 +++ b/txr.1 @@ -23417,9 +23417,10 @@ family, in the common situation when .meta string is the unbound argument. -.coNP Function @ split-str-set +.coNP Functions @ split-str-set and @ sspl .synb .mets (split-str-set < string << set ) +.mets (sspl < set << string ) .syne .desc The @@ -23449,6 +23450,14 @@ This operation is nondestructive: .meta string is not modified in any way. +The +.code sspl +function performs the same operation; the only difference between +.code sspl +and +.code split-str-set +is argument order. + .coNP Functions @ tok-str and @ tok-where .synb .mets (tok-str < string < regex <> [ keep-between ]) -- cgit v1.2.3