diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-01-23 00:17:33 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-01-23 00:17:33 -0800 |
commit | fca47effb1490e6308be3f9600fe782f3cdea862 (patch) | |
tree | aba86700388af886dc5884f9bd00ea2288c4f658 /txr.1 | |
parent | 9fa70b67bad4f95c22fa0e7a1148b88c82f375e1 (diff) | |
download | txr-fca47effb1490e6308be3f9600fe782f3cdea862.tar.gz txr-fca47effb1490e6308be3f9600fe782f3cdea862.tar.bz2 txr-fca47effb1490e6308be3f9600fe782f3cdea862.zip |
* lib.c (conses, lazy_conses, func_set_env): New functions.
(lazy_conses_func): New static function.
* lib.h (conses, lazy_conses, func_set_env): Declared.
* eval.c (eval_init): conses, lazy_conses and func_set_env registered
as intrinsics.
* txr.1: Documented.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 48 |
1 files changed, 47 insertions, 1 deletions
@@ -7027,12 +7027,58 @@ Examples: (mappend (lambda (item) (if (evenp x) (list x))) '(1 2 3 4 5)) -> (2 4) +.SS Functions conses and conses* + +.TP +Syntax: + + (conses <list>) + (conses* <list>) + +.TP +Description: + +These functions return a list whose elements are the conses which make +up <list>. The conses* function does this in a lazy way, avoiding the +computation of the entire list: it returns a lazy list of the conses of <list>. +The conses function computes the entire list before returning. + +The input <list> may be proper or improper. + +The first cons of a list is that list itself. The second cons is the rest +of the list, or (cdr <list>). The third cons is (cdr (cdr <list>)) and so on. + +.TP +Example: + + (conses '(1 2 3)) -> ((1 2 3) (2 3) (3)) + +.TP +Dialect Note: + +These functions are useful for simulating the maplist function found in +other dialects like Common Lisp. + +TXR Lisp's (conses x) can be expressed in Common Lisp as +(maplist #'identity x). + +Conversely, the Common Lisp operation (maplist function list) can be computed +in TXR Lisp as (mapcar function (conses list)). + +More generally, the Common Lisp operation + + (maplist function list0 list1 ... listn) + +can be expressed as: + + (mapcar function (conses list0) (conses list1) ... (conses listn)) + .SS Function apply .TP Syntax: -(apply <function> <arglist>) + (apply <function> <arglist>) .TP Description: |