summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-06-17 06:37:32 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-06-17 06:37:32 -0700
commit5b140a070a99937da7c0b1fac9c23b7a281be82f (patch)
tree8e127a4b5fedaa372738a9a9cec0a735d7ef0554 /txr.1
parent4a223e77f8bf67c9236232bce354d60951b25bed (diff)
downloadtxr-5b140a070a99937da7c0b1fac9c23b7a281be82f.tar.gz
txr-5b140a070a99937da7c0b1fac9c23b7a281be82f.tar.bz2
txr-5b140a070a99937da7c0b1fac9c23b7a281be82f.zip
* eval.c (eval_init): register tuples as intrinsic.
* lib.c (tuples_func): New static function. (tuples): New function. * lib.h (tuples): Declared. * txr.1: Documented.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.133
1 files changed, 33 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index b0accf49..503b7771 100644
--- a/txr.1
+++ b/txr.1
@@ -10257,6 +10257,39 @@ 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 tuples
+
+.TP
+Syntax:
+
+ (tuples <length> <sequence> [<fill-value>])
+
+.TP
+Description:
+
+The tuples function produces a lazy list which represents a reorganization
+of the elements of <sequence> into tuples of <length>, where <length>
+must be a positive integer.
+
+The length of the sequence might not be evenly divisible by the tuple length.
+In this case, if a <fill-value> argument is specified, then the last tuple
+is padded with enough repetitions of <fill-value> to make it have <length>
+elements. If <fill-value> is not specified, then the last tuple is left
+shorter than <length>.
+
+The output of the function is a list, but the tuples themselves are sequences
+of the same kind as <sequence>. If <sequence> is any kind of list, they
+are lists, and not lazy lists.
+
+.TP
+Examples:
+
+ (tuples 3 #(1 2 3 4 5 6 7 8) 0) -> (#(1 2 3) #(4 5 6) #(7 8 0))
+ (tuples 3 "abc") -> ("abc")
+ (tuples 3 "abcd") -> ("abc" "d")
+ (tuples 3 "abcd" #\z) -> ("abc" "dzz")
+ (tuples 3 (list 1 2) #\z) -> ((1 2 #\z))
+
.SS Function make-like
.TP