summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-06-06 09:17:40 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-06-06 09:17:40 -0700
commitc27a97c95c628ff1e49339f82537bbf3719ab75a (patch)
treee918d29f8232608c7a6605bc385cc4eba759a84d /txr.1
parent6892a6968691e4a5f0965acb83f7e6df202c6007 (diff)
downloadtxr-c27a97c95c628ff1e49339f82537bbf3719ab75a.tar.gz
txr-c27a97c95c628ff1e49339f82537bbf3719ab75a.tar.bz2
txr-c27a97c95c628ff1e49339f82537bbf3719ab75a.zip
Fixing issue with list-like iteration over generic sequences,
namely that empty strings and vectors are not nil. The nullify function is introduced. It is also exposed to users, as is the existing make_like function. * eval.c (mapcarv, mappendv, lazy_mapcar, lazy_mapcarv): Use nullify to handle non-list inputs correctly. (eval_init): Registering make_like and nullify as intrinsics. * lib.c (copy_list, to_seq, list_collect_nconc, list_collect_append, reverse, lazy_appendv_func, lazy_appendv, ldiff, memq, memql, memqual, remq, remql, remqual, remove_if, keep_if, rem_lazy_rec, remq_lazy, remql_lazy, remqual_lazy, remove_if_lazy, keep_if_lazy, countqual, countql, countq, count_if, some_satisfy, all_satisfy, none_satisfy, do_chain, chainv, do_and, andv, do_or, orv, cat_vec, assoc, assql, mapcar, mapcon, mappend, sort, multi_sort, find, find_if, posqual, posql, posq, pos, pos_if, set_diff, search): Use nullify for correctness. Some functions fixed so return sequence matches type of input sequence. (nullify): New function. * lib.h (nullify): Declared. * txr.1: Documented nullify and ake-like.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.146
1 files changed, 46 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index e34c5118..66698a38 100644
--- a/txr.1
+++ b/txr.1
@@ -10048,6 +10048,52 @@ The sort function is stable for sequences which are lists. This means that the
original order of items which are considered identical is preserved.
For strings and vectors, the sort is not stable.
+.SS Function make-like
+
+.TP
+Syntax:
+
+ (make-like <list> <ref-sequence>)
+
+.TP
+Description:
+
+The <list> argument must be a list. If <ref-sequence> is a sequence type,
+then <list> is converted to the same type of sequence and returned.
+Otherwise the original <list> is returned.
+
+Note: the make-like function is a helper which supports the development of
+unoptimized versions of a generic function that accepts any type of
+sequence as input, and produces a sequence of the same type as output.
+The implementation of such a function can internally accumulate a list, and
+then convert the resulting list to the same type as an input value
+by using make-like.
+
+.SS Function nullify
+
+.TP
+Syntax:
+
+ (nullify <sequence>)
+
+.TP
+Description:
+
+The nullify function returns nil if <sequence> is an empty sequence.
+Otherwise it returns <sequence> itself.
+
+Note: the nullify function is a helper to support unoptimized generic
+programming over sequences. Thanks to the generic behavior cdr, any
+sequence can be traversed using cdr functions, checking for the nil
+value as a terminator. This, however, breaks for empty sequences which are not
+lists, because they are not equal to nil: to car and cdr they look like
+a one-element sequence containing nil. The nullify function reduces all empty
+sequences to nil, thereby correcting the behavior of code which traverses
+sequences using cdr, and tests for termination with nil.
+
+.TP
+
+
.SH MATH LIBRARY
.SS Arithmetic functions +, -