From 15dda4428072bb741d6bf42fa4906b217fc2aeb1 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 11 Feb 2014 16:42:33 -0800 Subject: * eval.c (eval_init): Turn a require argument into an optional one for the functions some, all and none. * lib.c (some_satisfy, all_satisfy, none_satisfy): Add defaulting behavior for pred parameter. * txr.1: Document that the predicate function is optional in calls to some, all and none. --- ChangeLog | 11 +++++++++++ eval.c | 6 +++--- lib.c | 3 +++ txr.1 | 9 +++++---- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index a9495309..cdc54316 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2014-02-11 Kaz Kylheku + + * eval.c (eval_init): Turn a require argument into an optional + one for the functions some, all and none. + + * lib.c (some_satisfy, all_satisfy, none_satisfy): Add defaulting + behavior for pred parameter. + + * txr.1: Document that the predicate function is optional + in calls to some, all and none. + 2014-02-11 Kaz Kylheku Version 79 diff --git a/eval.c b/eval.c index eff15bb1..82aa8ea0 100644 --- a/eval.c +++ b/eval.c @@ -2412,9 +2412,9 @@ void eval_init(void) reg_fun(intern(lit("countql"), user_package), func_n2(countql)); reg_fun(intern(lit("countq"), user_package), func_n2(countq)); reg_fun(intern(lit("count-if"), user_package), func_n3o(count_if, 2)); - reg_fun(intern(lit("some"), user_package), func_n3o(some_satisfy, 2)); - reg_fun(intern(lit("all"), user_package), func_n3o(all_satisfy, 2)); - reg_fun(intern(lit("none"), user_package), func_n3o(none_satisfy, 2)); + reg_fun(intern(lit("some"), user_package), func_n3o(some_satisfy, 1)); + reg_fun(intern(lit("all"), user_package), func_n3o(all_satisfy, 1)); + reg_fun(intern(lit("none"), user_package), func_n3o(none_satisfy, 1)); reg_fun(intern(lit("eq"), user_package), eq_f); reg_fun(intern(lit("eql"), user_package), eql_f); reg_fun(intern(lit("equal"), user_package), equal_f); diff --git a/lib.c b/lib.c index 67784f4d..1b0199c2 100644 --- a/lib.c +++ b/lib.c @@ -1038,6 +1038,7 @@ val count_if(val pred, val list, val key) val some_satisfy(val list, val pred, val key) { + pred = default_arg(key, identity_f); key = default_arg(key, identity_f); for (; list; list = cdr(list)) { @@ -1053,6 +1054,7 @@ val all_satisfy(val list, val pred, val key) { val item = t; + pred = default_arg(key, identity_f); key = default_arg(key, identity_f); for (; list; list = cdr(list)) { @@ -1065,6 +1067,7 @@ val all_satisfy(val list, val pred, val key) val none_satisfy(val list, val pred, val key) { + pred = default_arg(key, identity_f); key = default_arg(key, identity_f); for (; list; list = cdr(list)) { diff --git a/txr.1 b/txr.1 index 827d9fd6..93aca12d 100644 --- a/txr.1 +++ b/txr.1 @@ -7369,9 +7369,9 @@ Examples: .TP Syntax: - (some []) - (all []) - (none []) + (some [ [] ]) + (all [ [] ]) + (none [ [] ]) .TP Description @@ -7380,7 +7380,8 @@ The some, all and none functions apply a predicate test function over a list of elements. If the argument is specified, then values are passed into , and is applied to the resulting values. If is omitted, the behavior is -as if is the identity function. +as if is the identity function. If is omitted, +the behavior is as if is the identity function. These functions have short-circuiting semantics and return conventions similar to the and and or operators. -- cgit v1.2.3