diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-08-07 13:09:42 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-08-07 13:09:42 -0700 |
commit | bde7b8dfe688ce05f445b5ed18f22d6b2a526c3a (patch) | |
tree | 51cdb9bd8ab7673dda15cbcbc5ac65be59ceb478 /lib.c | |
parent | 1a18561313f4a66e5e454b48c08be160d9fe6c18 (diff) | |
download | txr-bde7b8dfe688ce05f445b5ed18f22d6b2a526c3a.tar.gz txr-bde7b8dfe688ce05f445b5ed18f22d6b2a526c3a.tar.bz2 txr-bde7b8dfe688ce05f445b5ed18f22d6b2a526c3a.zip |
New spl and tok: variants of tok-str and split-str.
* eval.c (eval_init): Register spl and tok intrinsics.
* lib.c (spl, tok): New functions.
* txr.1: Documented.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -4202,6 +4202,13 @@ val split_str_keep(val str, val sep, val keep_sep) } } +val spl(val sep, val arg1, val arg2) +{ + return if3(missingp(arg2), + split_str_keep(arg1, sep, arg2), + split_str_keep(arg2, sep, arg1)); +} + val split_str(val str, val sep) { return split_str_keep(str, sep, nil); @@ -4287,6 +4294,13 @@ val tok_str(val str, val tok_regex, val keep_sep) return out; } +val tok(val tok_regex, val arg1, val arg2) +{ + return if3(missingp(arg2), + tok_str(arg1, tok_regex, arg2), + tok_str(arg2, tok_regex, arg1)); +} + val tok_where(val str, val tok_regex) { list_collect_decl (out, iter); |