summaryrefslogtreecommitdiffstats
path: root/lisplib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-01-12 07:04:03 -0800
committerKaz Kylheku <kaz@kylheku.com>2022-01-12 07:04:03 -0800
commita4fe85e6df2e308241984294a3d35353d7cc083a (patch)
tree51550488a40d121c489021aca4aad7fecaecf71c /lisplib.c
parent2e0f7c370fa5012cb54328eb0e73412cb3c59351 (diff)
downloadtxr-a4fe85e6df2e308241984294a3d35353d7cc083a.tar.gz
txr-a4fe85e6df2e308241984294a3d35353d7cc083a.tar.bz2
txr-a4fe85e6df2e308241984294a3d35353d7cc083a.zip
New macros: each-true, some-true, each-false, some-false.
* lisplib.c (arith_each_set_entries): Trigger autoload on new symbols. * stdilb/arith-each.tl (sys:arith-each): Generalize macro to handle short-circuiting logical operations. The op-iv parameter, which is a cons, is spread into two op and iv parameter. One new argument appears, short-circ. This specifies a code for short-circuiting behavior: t means iteration continues while the result is true; nil means it continues while it is nil, and + means iteration continues while the accumulator is nonzero. A new convention is in effect: the operator has to be specified as a list in order to request accumulating behavior, e.g (+) or (*). Otherwise the operator specifies a predicate that is applied to the forms, without taking into account the prior value. (sum-each, sum-each*, mul-each, mul-each*): Spread the op-iv arguments. Wrap the op argument in a list to request accumulation. In the case of mul-each and mul-each*, specify + for the short-circ argument, which means that iteration stops when the accumulator becomes zerop. sum-each and sum-each* specify : for the short-circ argument which is unrecognized, and so ther is no short-circuiting behavior. (each-true, some-true, each-false, some-false): New macros. * tests/016/arith.tl: New tests. * txr.1: Documented new macros and added note about possible short-circuiting in mul-each and mul-each*. * stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'lisplib.c')
-rw-r--r--lisplib.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lisplib.c b/lisplib.c
index bf88d921..80c8dc59 100644
--- a/lisplib.c
+++ b/lisplib.c
@@ -848,6 +848,7 @@ static val arith_each_set_entries(val dlt, val fun)
{
val name[] = {
lit("sum-each"), lit("mul-each"), lit("sum-each*"), lit("mul-each*"),
+ lit("each-true"), lit("some-true"), lit("each-false"), lit("some-false"),
nil
};
set_dlt_entries(dlt, name, fun);