This is the snakes Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 07:44:08 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
snakes
Python style generators for Common Lisp.
Ben McGunigle <bnmcgn@gmail.com>
Apache 2.0
cl-cont
(system).
closer-mop
(system).
fiveam
(system).
iterate
(system).
cl-utilities
(system).
alexandria
(system).
package.lisp
(file).
util.lisp
(file).
snakes.lisp
(file).
do-generators.lisp
(file).
itertools.lisp
(file).
iterate.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
snakes/snakes.asd
snakes/package.lisp
snakes/util.lisp
snakes/snakes.lisp
snakes/do-generators.lisp
snakes/itertools.lisp
snakes/iterate.lisp
snakes/util.lisp
package.lisp
(file).
snakes
(system).
extract-keywords
(function).
last-car
(function).
xsubseq
(function).
snakes/snakes.lisp
util.lisp
(file).
snakes
(system).
*snakes-multi-mode*
(special variable).
basic-generator
(class).
consume
(function).
defgenerator
(macro).
do-generator
(macro).
do-generator-value-list
(macro).
file->generator
(function).
function->generator
(function).
gen-lambda
(macro).
gen-lambda-with-sticky-stop
(macro).
generator->list
(function).
generatorp
(generic function).
initialize-instance
(method).
list->generator
(function).
list->generator-with-tail
(function).
mapc-generator
(function).
mapcar-generator
(function).
sequence->generator
(function).
take
(function).
value-func->generator
(function).
with-yield
(macro).
yield-all
(macro).
create-values-handler
(function).
if-generator
(macro).
insufficient-items
(condition).
snakes-error
(condition).
sticky-stop-lambda
(macro).
stream->generator
(function).
snakes/do-generators.lisp
snakes.lisp
(file).
snakes
(system).
do-generators
(macro).
multi-gen
(function).
bind-clause
(function).
fill-info
(function).
get-generator
(function).
get-nextval-func
(function).
next-generator-value
(function).
next-generator-value-filled
(function).
proc-list-spec
(function).
process-genspecs
(function).
snakes/itertools.lisp
do-generators.lisp
(file).
snakes
(system).
chain
(function).
combinations
(function).
combinations-with-replacement
(function).
compress
(function).
cycle
(function).
dropwhile
(function).
enumerate
(function).
groupby
(function).
icount
(function).
ifilter
(function).
ifilter-false
(function).
imap
(function).
islice
(function).
izip
(function).
izip-longest
(function).
permutations
(function).
product
(function).
reduce-generator
(function).
starmap
(function).
take-as-generator
(function).
takewhile
(function).
tee
(function).
append!
(function).
snakes/iterate.lisp
itertools.lisp
(file).
snakes
(system).
clause-for-in-generator-1
(macro).
Packages are listed by definition order.
snakes
cl-cont
.
common-lisp
.
iterate
.
*snakes-multi-mode*
(special variable).
basic-generator
(class).
chain
(function).
combinations
(function).
combinations-with-replacement
(function).
compress
(function).
consume
(function).
cycle
(function).
defgenerator
(macro).
do-generator
(macro).
do-generator-value-list
(macro).
do-generators
(macro).
dropwhile
(function).
enumerate
(function).
file->generator
(function).
function->generator
(function).
gen-lambda
(macro).
gen-lambda-with-sticky-stop
(macro).
generator->list
(function).
generatorp
(generic function).
groupby
(function).
icount
(function).
ifilter
(function).
ifilter-false
(function).
imap
(function).
islice
(function).
izip
(function).
izip-longest
(function).
list->generator
(function).
list->generator-with-tail
(function).
mapc-generator
(function).
mapcar-generator
(function).
multi-gen
(function).
permutations
(function).
product
(function).
reduce-generator
(function).
sequence->generator
(function).
starmap
(function).
take
(function).
take-as-generator
(function).
takewhile
(function).
tee
(function).
value-func->generator
(function).
with-yield
(macro).
yield-all
(macro).
append!
(function).
bind-clause
(function).
clause-for-in-generator-1
(macro).
create-values-handler
(function).
extract-keywords
(function).
fill-info
(function).
get-generator
(function).
get-nextval-func
(function).
if-generator
(macro).
insufficient-items
(condition).
last-car
(function).
next-generator-value
(function).
next-generator-value-filled
(function).
proc-list-spec
(function).
process-genspecs
(function).
snakes-error
(condition).
sticky-stop-lambda
(macro).
stream->generator
(function).
xsubseq
(function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Steps through the specified generator, binding the value it returns to var, then executing the body for each step. If multiple variables are specified and the generator returns multiple values, the extra values will be bound to the extra variables.
Like do-generator, except all values emitted by the generator are placed in a list under the user defined variable.
Simultaneously iterate through multiple generators at once. By default
do-generators terminates when the shortest generator ends, but individual
generators can be padded out with the :fill-value keyword. Do-generators can
also iterate over lists in parallel with generators. To use lists, start the genspec with the :list keyword. Eg:
(do-generators ((a (repeat 2))
(:list b ’(4 5 6))
(c (list->generator ’(8 9)) :fill-value 30))
(print (* a (+ b c))))
24
28
72
NIL
Version of lambda that wraps the anonymous function in an instance of the basic-generator class. This allows the lambda to be identified as a generator by its type. Basic-generator objects are derived from funcallable-standard-class, therefore they can be called as functions.
Walks through generator, re-yielding all of the items in it. Only meant for use inside of a defgenerator or with-yield block.
Chains a number of generators together head to tail. Eg:
(chain (list->generator ’(1 2 3) (list->generator ’(6 7))) -> 1 2 3 6 7
Emits every possible combination of the items in list in sets of size r. Eg: (combinations ’(a b c d) 2) -(values)-> (a b) (a c) (a d) (b c) (b d) (c d)
Emits every possible combination, including repetitions, of the items in list in sets of size r. Eg:
(combinations-with-replacement ’(a b c) 2) -(values)-> (a a) (a b) (a c)
(b b) (b c) (c c)
Moves through the data and selectors generators in parallel, only yielding elements of data that are paired with a value from selectors that evaluates to true. Eg:
(compress (list->generator ’(a b c d e f))
(list->generator ’(t nil t nil t t))) -> a c e f
Takes N items from generator gen, returning nothing. If the generator contains less than n items, consume will empty the generator silently if fail-if-short is set to nil, otherwise it will raise an error.
Repeatedly cycles through a list or generator, yielding its elements indefinitely. Eg:
(cycle ’(a b c d)) -> a b c d a b c d a b ...
Note that this tool may consume considerable storage if the source iterable is long.
Goes through generator, dropping the items until the predicate fails, then emits the rest of the source generator’s items. Eg:
(dropwhile (lambda (x) (< x 5))
(list->generator ’(1 4 6 4 1))) -> 6 4 1
Given a path, will attempt to open the file specified and emit it line by line. Note: it will not close the file until the generator is exhausted.
Returns a generator that repeatedly calls source-func, tests the result against the predicate function, terminates when the predicate tests false, otherwise yielding the result
Groups the items from generator by the results of the key func. Each item emitted by groupby will be a pair: the key value, followed by a list of items that produced the key value when passed to the key function. Note: groupby does NOT sort the source generator. In other words it will only group matching items that are adjacent. To get SQL style GROUP BY functionality, sort the source generator before passing it to groupby. Eg:
(groupby (list->generator ’(A A A A B B B C C))) ->
(A (A A A A)) (B (B B B)) ...
Make a generator that returns evenly spaced values starting with n. Step can be fractional. Eg:
(counter 10) -> 10 11 12 13 14 ...
(counter 2.5 0.5) -> 2.5 3.0 3.5 ...
Emits only those items in generator that are true by predicate. The generator equivalent of remove-if-not
Emits only those items in generator that are false by predicate. The generator equivalent of remove-if
The generator equivalent of the mapcar function. Applies function to the
values of the supplied generators, emitting the result. Eg:
(imap #’* (list->generator ’(2 3 4)) (list->generator ’(4 5 6))) -> 8 15 24
Emits a subrange of generator. If only stop-or-start is set, islice will emit up to it and stop. If both stop-or-start and stop are set, islice will emit the stretch between stop and start. If step is set, then islice will emit every step-th item between start and stop. If stop is set to nil, then islice will continue through the source generator until it terminates. Eg:
(islice (list->generator ’(a b c d e f g)) 2) -> A B
(islice (list->generator ’(a b c d e f g)) 2 4) -> C D
(islice (list->generator ’(a b c d e f g)) 2 nil) -> C D E F G
(islice (list->generator ’(a b c d e f g)) 0 nil 2) -> A C E G
Steps through multiple generators in parallel, emitting each of their items as values. Stops with the end of the shortest source generator.
Steps through multiple generators in parallel, emitting each of their items as values. Keeps going until the end of the longest source generator, padding the rest out with the value specified by :fill-value
Emits every possible permutation of the items in list in a set of size r. If r is not specified, the size of list is used. Eg:
(permutations ’(a b c d) 2) -(values)-> (a b) (a c) (a d) (b a) (b c) (b d)
(c a) (c b) (c d) (d a) (d b) (d c)
Iterates through each of the supplied lists with nested dolists, yielding an element from each for every iteration of the innermost loop. The yielded values cycle in an odometer-like fashion, with the first value changing seldom and the last changing on every yield. Eg: (product ’(a b c d) ’(x y)) -(values)-> (a x) (a y) (b x) (b y) (c x) (c y)...
Reduce items from generator using a binary operation
FUNCTION. Reduction is left-associative. Optional INITIAL-VALUE is
logically placed before items in the generator. Eg:
(foldl #’+ (list->generator ’(1 2 3 4))) -> 10
For consistency with CL:REDUCE do the following if the generator has insufficient items:
* If GENERATOR has no values, return result of FUNCTION called without arguments.
* If GENERATOR has exactly one item, return that item.
Sequentially applies the function to the output of the generator. Like imap, but assumes that the contents of the generator are already merged. Eg: (starmap #’expt (list->generator ’((2 5) (3 2) (10 3)))) -> 32 9 1000
Takes n items from generator gen, returning them as a list. If the generator contains less than n items, take will return what is available if fail-if-short is set to nil, otherwise it will raise an error.
This function has the same meaning as TAKE but returns a generator
instead of a list. Eg:
(generator->list (take-as-generator 10 (list->generator ’(1 2 3)))) -> Signals a condition (generator->list (take-as-generator 10 (list->generator ’(1 2 3)) :fail-if-short nil)) -> (1 2 3) (generator->list (take-as-generator 3 (repeat 1))) -> (1 1 1)
Emits items from generator until predicate fails. Eg: (takewhile (lambda (x) (< x 5)) (list->generator ’(1 4 6 4 1))) -> 1 4
Creates independent copies of generator, returned as values. If the child generators are consumed at different times, tee will store all of the items from the least consumed child generator through to the most. It can, if used incautiously, require considerable memory.
Note also that this implementation of tee does not create independent copies of the parent items. Modifying items from a child generator and tampering with the parent generator have undefined consequences.
Converts to a generator that sort of function which uses the second value as
a completion signal. Will keep emitting the first return value of the source function until the second value is a nil.
basic-generator
)) ¶basic-generator
) &key function) ¶funcallable-standard-object
.
Iterate through a snakes generator
Pulls a single iteration out of gen. If a single var is specified, it places all the values from the iteration in a list under var. If var is a list, destructures values into the vars in the list. If the generator has stopped, evaluates false-clause, otherwise evaluates true-clause.
Once a generator function has sent a generator-stop symbol, it should continue to do so every time it is called. This macro helps with obeying that rule.
Returns a function to transform ready-to-be-yielded values according to *snakes-multi-mode*. This should be set up at generator creation time, not at consumption time, so that generators in a chain can be set individually.
Returns a closure that acts like next-generator-value, but returns fill when the generator runs out. The :filled keyword instead of T in the first value slot still evaluates as true, but indicates that the generator has ended.
Emits stream line at a time as a generator.
Returns sequence with start->end chopped out of it
Jump to: | A B C D E F G I L M N P R S T V W X Y |
---|
Jump to: | A B C D E F G I L M N P R S T V W X Y |
---|
Jump to: | *
S |
---|
Index Entry | Section | ||
---|---|---|---|
| |||
* | |||
*snakes-multi-mode* : | Public special variables | ||
| |||
S | |||
Special Variable, *snakes-multi-mode* : | Public special variables | ||
|
Jump to: | *
S |
---|
Jump to: | B C D F I P S U |
---|
Jump to: | B C D F I P S U |
---|