Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the cl-itertools Reference Manual, version 0.2, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 11:11:33 2018 GMT+0.
• Introduction: | What cl-itertools is all about | |
• Systems: | The systems documentation | |
• Files: | The files documentation | |
• Packages: | The packages documentation | |
• Definitions: | The symbols documentation | |
• Indexes: | Concepts, functions, variables and data types |
This is a port of Python itertools, that is a part of standard library, to CL. Original Python docs: https://docs.python.org/2/library/itertools.html
Also it defines couple of primitives, that make writing iterators in CL a joy (at least, for me).
To avoid collisions with CL names the "i" prefix is added to all functions. Thus, they are:
The summary of things, that make working with iterators more convenient. For examples of use, see cl-itertools.lisp itself.
Iterators are implemented on top of CL-COROUTINE system.
To ease the work with iterators there is a universal "IN-IT" driver for ITERATE
(iter (for i in-it (irange 4 10))
(collect i))
--> (4 5 6 7 8 9)
To ease definition of new iterators, there is "DEFITER" macro. The syntax is prettly self-explanatory, for example, ICOUNT is defined like
(defiter icount (start &optional (step 1))
(let ((cur start))
(iter (while t)
(yield cur)
(incf cur step))))
On each successful invocation of iterator (underlying iterator coroutine), YIELD form has a value, which is supplied to the coroutine on this invocation.
For example, let's define iterator that just prints whatever is supplied to it (and returns successive integers:
(defiter just-a-printer ()
(iter (for i from 1)
(format t "~a~%" (yield i))))
(defparameter *a* (just-a-printer))
(inext-noexit *a* 'a)
1
T
(inext-noexit *a* 'b)
B
2
T
(inext-noexit *a* 'c)
C
3
T
This example also shows use of INEXT-NOEXIT macro, which fetches next value from iterator. Note how symbol A is not printed on first call to INEXT-NOEXIT (because control flow is returned from YIELD, before FORMAT is entered). On second call to INEXT-NOEXIT symbol 'B is correctly printed and the next integer -- 2 -- is returned. Second value T is an artefact of realization.
We can modify this example, so that it would also print symbol A
(defiter just-a-printer ()
(format t "~a~%" (yield-last-value))
(iter (for i from 1)
(format t "~a~%" (yield i))))
(defparameter *a* (just-a-printer))
(inext-noexit *a* 'a)
A
1
T
(inext-noexit *a* 'b)
B
2
T
For this we need to use (YIELD-LAST-VALUE) macrolet, that always gives the last value, supplied to iterator (to the coroutine) by its caller. Thus, before we encountered any YIELDs in the control flow of the iterator, this value is equal to the value first supplied to the iterator (i.e. 'A).
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The cl-itertools system: |
Alexandr Popolitov <popolit@gmail.com>
MIT
itertools Python lib ported to CL
0.2
cl-itertools.asd (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files: |
• The cl-itertools.asd file: | ||
• The cl-itertools/package.lisp file: | ||
• The cl-itertools/cl-itertools.lisp file: |
Next: The cl-itertools/package<dot>lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
cl-itertools.asd
cl-itertools (system)
Next: The cl-itertools/cl-itertools<dot>lisp file, Previous: The cl-itertools<dot>asd file, Up: Lisp files [Contents][Index]
cl-itertools (system)
package.lisp
Previous: The cl-itertools/package<dot>lisp file, Up: Lisp files [Contents][Index]
package.lisp (file)
cl-itertools (system)
cl-itertools.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The cl-itertools-system package: | ||
• The cl-itertools package: |
Next: The cl-itertools package, Previous: Packages, Up: Packages [Contents][Index]
cl-itertools.asd
Previous: The cl-itertools-system package, Up: Packages [Contents][Index]
package.lisp (file)
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions: | ||
• Internal definitions: |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported macros: | ||
• Exported functions: | ||
• Exported generic functions: | ||
• Exported conditions: |
Next: Exported functions, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
cl-itertools.lisp (file)
cl-itertools.lisp (file)
cl-itertools.lisp (file)
Iter is supposed to be created using DEFITER or MK-ITER – hence its coro always accepts an arg.
cl-itertools.lisp (file)
Like INEXT, only when iterator is depleted, return (VALUES NIL NIL) and don’t COEXIT.
cl-itertools.lisp (file)
cl-itertools.lisp (file)
The coroutine argument is passed through YIELD macro.
cl-itertools.lisp (file)
Next: Exported generic functions, Previous: Exported macros, Up: Exported definitions [Contents][Index]
cl-itertools.lisp (file)
cl-itertools.lisp (file)
cl-itertools.lisp (file)
start, start + step, start + 2*step, ...
cl-itertools.lisp (file)
p0, p1, ... plast, p0, p1, ...
cl-itertools.lisp (file)
cl-itertools.lisp (file)
cl-itertools.lisp (file)
cl-itertools.lisp (file)
cl-itertools.lisp (file)
cl-itertools.lisp (file)
cl-itertools.lisp (file)
elem, elem, elem, ... endlessly or up to n times
cl-itertools.lisp (file)
cl-itertools.lisp (file)
cl-itertools.lisp (file)
cl-itertools.lisp (file)
cl-itertools.lisp (file)
Next: Exported conditions, Previous: Exported functions, Up: Exported definitions [Contents][Index]
cl-itertools.lisp (file)
Previous: Exported generic functions, Up: Exported definitions [Contents][Index]
cl-itertools.lisp (file)
error (condition)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal macros: | ||
• Internal functions: | ||
• Internal generic functions: | ||
• Internal classes: |
Next: Internal functions, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
cl-itertools.lisp (file)
cl-itertools.lisp (file)
Next: Internal generic functions, Previous: Internal macros, Up: Internal definitions [Contents][Index]
cl-itertools.lisp (file)
Return list (KWD1 KWD2 ... KWDn . OTHER-ARGS) collecting all keyword-looking pairs of arguments in lambda list
cl-itertools.lisp (file)
Next: Internal classes, Previous: Internal functions, Up: Internal definitions [Contents][Index]
automatically generated reader method
cl-itertools.lisp (file)
automatically generated writer method
cl-itertools.lisp (file)
Previous: Internal generic functions, Up: Internal definitions [Contents][Index]
cl-itertools.lisp (file)
standard-object (class)
:coro
i-coro (generic function)
(setf i-coro) (generic function)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index: | ||
• Function index: | ||
• Variable index: | ||
• Data type index: |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | C F L |
---|
Jump to: | C F L |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | (
C D F G I L M P |
---|
Jump to: | (
C D F G I L M P |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | C S |
---|
Index Entry | Section | ||
---|---|---|---|
| |||
C | |||
coro : | Internal classes | ||
| |||
S | |||
Slot, coro : | Internal classes | ||
|
Jump to: | C S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | C I P S |
---|
Jump to: | C I P S |
---|