summaryrefslogtreecommitdiffstats
path: root/rand.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-02-27 21:08:14 -0800
committerKaz Kylheku <kaz@kylheku.com>2024-02-27 21:08:14 -0800
commitfb09dfc8559a5b01c75b691613cf9eda54f7bee5 (patch)
treedc54324ff4f6210606eec3d8f1be85b094cfe27b /rand.h
parent1291aa76a9c85ac50bc5ebe968fd332bdfe80af0 (diff)
downloadtxr-fb09dfc8559a5b01c75b691613cf9eda54f7bee5.tar.gz
txr-fb09dfc8559a5b01c75b691613cf9eda54f7bee5.tar.bz2
txr-fb09dfc8559a5b01c75b691613cf9eda54f7bee5.zip
seq_build: support improper lists.
To be useful for some operations, the seq_build framework must handle the pend operation on lists specially. The appended piece must only be treated as a sequence if it is a cons. Moreover, if it is an atom, or of it is an improper list, then the list terminates. Subsequent add and pend operations must fail. The atom must appear as the terminator. We meet these objectives by switching the object's operations, sb_list_ops, to a new set of operations, sb_improper_ops. * lib.c (seq_build_list_pend): New static function. This individually adds all items from the input list, until it hits a terminating atom. If the atom isn't nil, it converts the seq_build_t object to improper operations. (seq_build_improper_add, seq_build_improper_pend): New static functions. These throw an error: adding anything to an improper list is impossible. (seq_build_improper_finish): New function, which does nothing: the improper list is finished already. (sb_list_ops): Use the seq_build_list_pend operation rather than the generic one. (sb_improper_ops): New static structure. (seq_build_convert_to_improper): New static function. Finishes the list, giving it the specified terminating atom, and then switches to sb_improper_ops so that adding is no longer possible.
Diffstat (limited to 'rand.h')
0 files changed, 0 insertions, 0 deletions