diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-02-11 16:42:33 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-02-11 16:42:33 -0800 |
commit | 15dda4428072bb741d6bf42fa4906b217fc2aeb1 (patch) | |
tree | 56e8975170bac4dbf3c5cfa526b59667066732eb | |
parent | 8910536efaa12182a4ae0158783a1bb1426cdf04 (diff) | |
download | txr-15dda4428072bb741d6bf42fa4906b217fc2aeb1.tar.gz txr-15dda4428072bb741d6bf42fa4906b217fc2aeb1.tar.bz2 txr-15dda4428072bb741d6bf42fa4906b217fc2aeb1.zip |
* 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.
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | eval.c | 6 | ||||
-rw-r--r-- | lib.c | 3 | ||||
-rw-r--r-- | txr.1 | 9 |
4 files changed, 22 insertions, 7 deletions
@@ -1,5 +1,16 @@ 2014-02-11 Kaz Kylheku <kaz@kylheku.com> + * 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 <kaz@kylheku.com> + Version 79 * txr.c (version): Bumped. @@ -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); @@ -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)) { @@ -7369,9 +7369,9 @@ Examples: .TP Syntax: - (some <list> <predicate-fun> [<key-fun>]) - (all <list> <predicate-fun> [<key-fun>]) - (none <list> <predicate-fun> [<key-fun>]) + (some <list> [ <predicate-fun> [<key-fun>] ]) + (all <list> [ <predicate-fun> [<key-fun>] ]) + (none <list> [ <predicate-fun> [<key-fun>] ]) .TP Description @@ -7380,7 +7380,8 @@ The some, all and none functions apply a predicate test function <predicate-fun> over a list of elements. If the argument <key-fun> is specified, then values <list> are passed into <key-fun>, and <predicate-fun> is applied to the resulting values. If <key-fun> is omitted, the behavior is -as if <key-fun> is the identity function. +as if <key-fun> is the identity function. If <predicate-fun> is omitted, +the behavior is as if <predicate-fun> is the identity function. These functions have short-circuiting semantics and return conventions similar to the and and or operators. |