diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | eval.c | 11 | ||||
-rw-r--r-- | txr.1 | 27 |
3 files changed, 45 insertions, 0 deletions
@@ -1,5 +1,12 @@ 2014-06-20 Kaz Kylheku <kaz@kylheku.com> + * eval.c (do_apf, apf): New functions. + (eval_init): Register apf as intrinsic. + + * txr.1: Document apf. + +2014-06-20 Kaz Kylheku <kaz@kylheku.com> + Improve error reporting. * eval.c (eval_error): Use last_form_evaled if form is null. @@ -3104,6 +3104,16 @@ static val retf(val ret) return func_f0v(ret, do_retf); } +static val do_apf(val fun, val args) +{ + return apply(fun, args, nil); +} + +static val apf(val fun) +{ + return func_f1(fun, do_apf); +} + static val prinl(val obj, val stream) { val ret = obj_print(obj, stream); @@ -3456,6 +3466,7 @@ void eval_init(void) reg_fun(intern(lit("or"), user_package), func_n0v(or_fun)); reg_fun(intern(lit("and"), user_package), func_n0v(and_fun)); reg_fun(intern(lit("retf"), user_package), func_n1(retf)); + reg_fun(intern(lit("apf"), user_package), func_n1(apf)); reg_fun(intern(lit("tf"), user_package), func_n0v(tf)); reg_fun(intern(lit("nilf"), user_package), func_n0v(nilf)); @@ -11957,6 +11957,8 @@ except that the symbol args is to be understood as a generated symbol (gensym). The ap macro nests properly with op and do, in any combination, in regard to the @@n notation. +See also: the apf function. + .SS Macro ret .TP @@ -12157,6 +12159,31 @@ Example: ;; the function returned by (retf 42) ignores 1 2 3 and returns 42. (call (retf 42) 1 2 3) -> 42 +.SH Function apf + +.TP +Syntax: + + (apf <function>) + +.TP +Description: + +The apf function returns a one-argument function which accepts +a list. When the function is called, it treats the list as +argument which are applied to <function>. It returns whatever +<function> returns. + +See also: the ap macro. + +.TP +Example: + + ;; Function returned by [apf +] accepts (1 2 3) list and + ;; applies it to +, as if (+ 1 2 3) were called. + + (call [apf +] '(1 2 3)) -> 6 + .SH INPUT AND OUTPUT (STREAMS) TXR Lisp supports input and output streams of various kinds, with |