summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-06-28 11:47:13 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-06-28 11:47:13 -0700
commit931ee402f18da5c2eeeefb5d6f1217c833e04508 (patch)
tree7f7331a7e3484faa9a13c530b87c6aa4df4c765d /eval.c
parenta6a7e5ea61164c2f721fa353c578aeb2688f04a3 (diff)
downloadtxr-931ee402f18da5c2eeeefb5d6f1217c833e04508.tar.gz
txr-931ee402f18da5c2eeeefb5d6f1217c833e04508.tar.bz2
txr-931ee402f18da5c2eeeefb5d6f1217c833e04508.zip
New function: maprodo.
maprodo is like maprod, but doesn't collect or return anything. It's the Cartesian product analog of mapdo. * eval.c (collect_nothing, maprodo): New static functions. (eval_init): Register maprodo intrinsic. * txr.1: Documented.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/eval.c b/eval.c
index cd282da0..1d1b6cf0 100644
--- a/eval.c
+++ b/eval.c
@@ -5463,6 +5463,17 @@ val maprendv(val fun, struct args *lists)
return prod_common(fun, lists, list_collect_append, mappendv);
}
+static loc collect_nothing(loc ptail, val obj)
+{
+ (void) obj;
+ return ptail;
+}
+
+static val maprodo(val fun, struct args *lists)
+{
+ return prod_common(fun, lists, collect_nothing, mappendv);
+}
+
static val symbol_value(val sym)
{
uses_or2;
@@ -6535,6 +6546,7 @@ void eval_init(void)
reg_fun(intern(lit("mapdo"), user_package), func_n1v(mapdov));
reg_fun(intern(lit("maprod"), user_package), func_n1v(maprodv));
reg_fun(intern(lit("maprend"), user_package), func_n1v(maprendv));
+ reg_fun(intern(lit("maprodo"), user_package), func_n1v(maprodo));
reg_fun(intern(lit("window-map"), user_package), func_n4(window_map));
reg_fun(intern(lit("window-mappend"), user_package), func_n4(window_mappend));
reg_fun(intern(lit("window-mapdo"), user_package), func_n4(window_mapdo));