diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-03-09 07:07:59 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-03-09 07:07:59 -0800 |
commit | 7450285654ee48e010199f2e615a3451e09872f4 (patch) | |
tree | c97f186f1e334b67bd1a0385c30d73b943f04b12 /eval.c | |
parent | f33ace67e4e0760a423b460bb76ad2b99f49b2cd (diff) | |
download | txr-7450285654ee48e010199f2e615a3451e09872f4.tar.gz txr-7450285654ee48e010199f2e615a3451e09872f4.tar.bz2 txr-7450285654ee48e010199f2e615a3451e09872f4.zip |
lib: new functions join, join-with.
That old cat-str function is often a pain, requiring the
pieces as a list. We have a sys:fmt-join that is undocumented.
That functions is now exposed as usr:join, and documented.
Also introducing join-with that takes a separator as the
leftmost argument. Thus (op join-with "::") gives us
a function that joins pieces with :: in between.
* eval.c (eval_init): Regiser fmt_join function under join
symbol also. Register join-with.
* lib.c (join_with): New function.
(fmt_join): Now a wrapper for join_with that passes a nil
separator.
* lib.h (join_with): Declared.
* share/txr/stdlib/optimize.tl (basic-blocks join-blocks):
Rename the local function join, which now triggers a warning
about a standard function being redefined.
* txr.1: Redocumented cat-str, and documented join-with
and join.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -6798,7 +6798,12 @@ void eval_init(void) reg_fun(intern(lit("fmt-simple"), system_package), func_n5o(fmt_simple, 1)); reg_fun(intern(lit("fmt-flex"), system_package), func_n2v(fmt_flex)); - reg_fun(intern(lit("fmt-join"), system_package), func_n0v(fmt_join)); + { + val join_f = func_n0v(fmt_join); + reg_fun(intern(lit("fmt-join"), system_package), join_f); + reg_fun(intern(lit("join"), user_package), join_f); + } + reg_fun(intern(lit("join-with"), user_package), func_n1v(join_with)); reg_varl(user_package_s = intern(lit("user-package"), user_package), user_package); reg_varl(system_package_s = intern(lit("system-package"), user_package), system_package); |