The sequence-utilities Module¶
Overview¶
The sequence-utilities module implements some useful methods on sequences.
Reference¶
TODO: These docs are just an auto-generated skeleton so far. https://github.com/dylan-lang/collection-extensions/issues/2
- alist-copy Function¶
- Signature:
alist-copy (alist #key key datum cons) => (new-alist)
- Parameters:
alist – An instance of
<sequence>.key (#key) – An instance of
<object>.datum (#key) – An instance of
<object>.cons (#key) – An instance of
<object>.
- Values:
new-alist – An instance of
<sequence>.
- alist-delete Function¶
- Signature:
alist-delete (elt alist #key key test) => (#rest results)
- Parameters:
elt – An instance of
<object>.alist – An instance of
<sequence>.key (#key) – An instance of
<object>.test (#key) – An instance of
<object>.
- Values:
#rest results – An instance of
<object>.
- apair Function¶
- Signature:
apair (key datum aseq #key cons add) => (new-aseq)
- Parameters:
key – An instance of
<object>.datum – An instance of
<object>.aseq – An instance of
<sequence>.cons (#key) – An instance of
<object>.add (#key) – An instance of
<object>.
- Values:
new-aseq – An instance of
<sequence>.
- assoc Function¶
- Signature:
assoc (elt seq #key key test) => (#rest results)
- Parameters:
elt – An instance of
<object>.seq – An instance of
<sequence>.key (#key) – An instance of
<object>.test (#key) – An instance of
<object>.
- Values:
#rest results – An instance of
<object>.
- choose-map Generic function¶
- choose-map(<function>, <function>, <sequence>) Method¶
- choose-map(<function>, <function>, <list>) Method¶
- concatenate-map Generic function¶
- concatenate-map(<function>, <sequence>) Method¶
- concatenate-map(<function>, <list>) Method¶
- drop Open Generic function¶
- drop(<sequence>, <integer>) Method¶
- find Generic function¶
- Signature:
find (pred seq #key failure) => (#rest results)
- Parameters:
pred – An instance of
<function>.seq – An instance of
<sequence>.failure (#key) – An instance of
<object>.
- Values:
#rest results – An instance of
<object>.
- find-tail Generic function¶
- find-tail(<function>, <sequence>) Method¶
- find-tail(<function>, <pair>) Method¶
- find-tail(<function>, <empty-list>) Method¶
- foldl Function¶
- Signature:
foldl (cons nil lst) => (#rest results)
- Parameters:
cons – An instance of
<function>.nil – An instance of
<object>.lst – An instance of
<list>.
- Values:
#rest results – An instance of
<object>.
- foldr Function¶
- Signature:
foldr (cons nil lst) => (#rest results)
- Parameters:
cons – An instance of
<function>.nil – An instance of
<object>.lst – An instance of
<list>.
- Values:
#rest results – An instance of
<object>.
- heads Function¶
- index Generic function¶
- Signature:
index (elt seq #key test failure) => (index)
- Parameters:
elt – An instance of
<object>.seq – An instance of
<sequence>.test (#key) – An instance of
<object>.failure (#key) – An instance of
<object>.
- Values:
index – An instance of
<object>.
- last-pair Function¶
- list* Function¶
- list? Generic function¶
- list?(<list>) Method¶
- list?(<object>) Method¶
- null? Generic function¶
- null?(<empty-list>) Method¶
- null?(<object>) Method¶
- pair-do Function¶
- Signature:
pair-do (func lst #rest lists) => (false)
- Parameters:
func – An instance of
<function>.lst – An instance of
<list>.lists (#rest) – An instance of
<object>.
- Values:
false – An instance of
<boolean>.
- pair-foldl Function¶
- Signature:
pair-foldl (cons nil lst) => (#rest results)
- Parameters:
cons – An instance of
<function>.nil – An instance of
<object>.lst – An instance of
<list>.
- Values:
#rest results – An instance of
<object>.
- pair-foldr Function¶
- Signature:
pair-foldr (cons nil lst) => (#rest results)
- Parameters:
cons – An instance of
<function>.nil – An instance of
<object>.lst – An instance of
<list>.
- Values:
#rest results – An instance of
<object>.
- pair? Generic function¶
- pair?(<pair>) Method¶
- pair?(<object>) Method¶
- partition Function¶
- Signature:
partition (pred seq) => (winners losers)
- Parameters:
pred – An instance of
<function>.seq – An instance of
<sequence>.
- Values:
- pop! Macro¶
- precedes? Generic function¶
- Signature:
precedes? (elt-1 elt-2 seq #key test not-found) => (precedes?)
- Parameters:
elt-1 – An instance of
<object>.elt-2 – An instance of
<object>.seq – An instance of
<sequence>.test (#key) – An instance of
<object>.not-found (#key) – An instance of
<object>.
- Values:
precedes? – An instance of
<boolean>.
- push! Macro¶
- reduce-l Function¶
- Signature:
reduce-l (cons nil lst) => (#rest results)
- Parameters:
cons – An instance of
<function>.nil – An instance of
<object>.lst – An instance of
<list>.
- Values:
#rest results – An instance of
<object>.
- reduce-r Function¶
- Signature:
reduce-r (cons nil lst) => (#rest results)
- Parameters:
cons – An instance of
<function>.nil – An instance of
<object>.lst – An instance of
<list>.
- Values:
#rest results – An instance of
<object>.
- reverse-append Open Generic function¶
- Signature:
reverse-append (reversed-head tail) => (new-sequence)
- Parameters:
reversed-head – An instance of
<sequence>.tail – An instance of
<sequence>.
- Values:
new-sequence – An instance of
<sequence>.
- reverse-append(<sequence>, <sequence>) Method¶
- reverse-append(<list>, <list>) Method¶
- satisfies Generic function¶
- Signature:
satisfies (pred seq #key failure) => (index)
- Parameters:
pred – An instance of
<function>.seq – An instance of
<sequence>.failure (#key) – An instance of
<object>.
- Values:
index – An instance of
<object>.
- tabulate Function¶
- Signature:
tabulate (length func #key type) => (#rest results)
- Parameters:
length – An instance of
<integer>.func – An instance of
<function>.type (#key) – An instance of
<object>.
- Values:
#rest results – An instance of
<object>.
- tails Function¶
- take Open Generic function¶
- take(<sequence>, <integer>) Method¶
- unfold Function¶
- Signature:
unfold (pred f g seed) => (new-list)
- Parameters:
pred – An instance of
<function>.f – An instance of
<function>.g – An instance of
<function>.seed – An instance of
<object>.
- Values:
new-list – An instance of
<list>.
- unfold/tail Function¶
- Signature:
unfold/tail (pred f g e seed) => (new-list)
- Parameters:
pred – An instance of
<function>.f – An instance of
<function>.g – An instance of
<function>.e – An instance of
<function>.seed – An instance of
<object>.
- Values:
new-list – An instance of
<list>.
- xpair Function¶
zip¶
- zip Function¶
The zip function combines multiple iterables element-wise into tuples, stopping at the shortest iterable.
- Signature:
zip (sequence1 sequence2 #key key1 key2) => (zipped)
- Parameters:
sequence1 – An instance of
<sequence>.sequence2 – An instance of
<sequence>.key1 (#key) – An instance of
<function>. Default value:identity.key2 (#key) – An instance of
<function>. Default value:identity.
- Values:
zipped – An instance of
<sequence>.
- Discussion:
The zip function is often classified as a high-order function and a sequence transformation function.
The function operates on two sequences (like
range, array,list, deque or string) and transforms them in a<sequence>of pairs, each element from one of the sequences.If key1 or key2 are not provided, they default to the function
identityreturning the object. If provided, this function transforms the element before collecting it.If the sequences provided have different lengths, func:zip automatically truncates the output to the length of the shorter sequence.
- Example:
let a = #(1, 2); let b = #('a', 'b'); let zipped = zip(a, b); format-out("%=", zipped); // Output: #(#(1, 'a'), #(2, 'b'))
- Example:
let a = #('a', 'b'); let b = #(3, 4); let zipped = zip(a, b, key2: odd?); format-out("%=", zipped); // Output: #(#('a', #t), ('b', #f))
zip-with¶
- zip-with Function¶
- Signature:
zip-with (function collection #rest more-collections) ⇒ new-collection
- Parameters:
function – An instance of
<function>.collection – An instance of
<collection>.more-collections – An instance of
<collection>.
- Values:
new-collection – An instance of
<collection>.
- Example:
let a = #(100, 200, 300); let b = #(1, 2, 3); let zipped = zip-with(\+, a, b); format-out("%=", zipped); // Output: #(101, 202, 303)
- See also:
zip-all¶
- zip-all Function¶
A
zipfunction that can take any number of iterables as parameters.- Signature:
zip-all (sequences) => (zipped)
- Parameters:
sequences – An instance of
<sequence>.
- Values:
zipped – An instance of
<sequence>.
- Example:
let a = #(1, 2, 3); let b = #('a', 'b', 'c'); let c = #(#t, #f, #t); let zipped = zip-all(a, b, c); format-out("%=", zipped); // Output: #(#(1, 'a', #t), #(2, 'b', #f), #(3, 'c', #t))