The cl-itertools Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The cl-itertools Reference Manual

This is the cl-itertools Reference Manual, version 0.2, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 03:22:21 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

cl-itertools

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:

Defined utils

The summary of things, that make working with iterators more convenient. For examples of use, see cl-itertools.lisp itself.

Technicalities

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).

TODO


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 cl-itertools

Author

Alexandr Popolitov <popolit@gmail.com>

License

MIT

Description

itertools Python lib ported to CL

Version

0.2

Dependencies
Source

cl-itertools.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 cl-itertools.asd

Location

cl-itertools.asd

Systems

cl-itertools (system)

Packages

cl-itertools-system


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 cl-itertools/package.lisp

Parent

cl-itertools (system)

Location

package.lisp

Packages

cl-itertools


Previous: , Up: Lisp files   [Contents][Index]

3.1.3 cl-itertools/cl-itertools.lisp

Dependency

package.lisp (file)

Parent

cl-itertools (system)

Location

cl-itertools.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

4.1 cl-itertools-system

Source

cl-itertools.asd

Use List

Previous: , Up: Packages   [Contents][Index]

4.2 cl-itertools

Source

package.lisp (file)

Use List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Macros

Macro: coexit! ()
Package

cl-itertools

Source

cl-itertools.lisp (file)

Macro: def-launched-iter NAME ARGS &body BODY
Package

cl-itertools

Source

cl-itertools.lisp (file)

Macro: defiter NAME ARGS &body BODY
Package

cl-itertools

Source

cl-itertools.lisp (file)

Macro: inext ITER-VAR &optional ARG

Iter is supposed to be created using DEFITER or MK-ITER – hence its coro always accepts an arg.

Package

cl-itertools

Source

cl-itertools.lisp (file)

Macro: inext-noexit ITER-VAR &optional ARG

Like INEXT, only when iterator is depleted, return (VALUES NIL NIL) and don’t COEXIT.

Package

cl-itertools

Source

cl-itertools.lisp (file)

Macro: inext-or-error ITER-VAR &optional ARG
Package

cl-itertools

Source

cl-itertools.lisp (file)

Macro: lambda-coro &body BODY

The coroutine argument is passed through YIELD macro.

Package

cl-itertools

Source

cl-itertools.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: collect-iter THING
Package

cl-itertools

Source

cl-itertools.lisp (file)

Function: ichain &rest THINGS
Package

cl-itertools

Source

cl-itertools.lisp (file)

Function: icompress DATA SELECTORS
Package

cl-itertools

Source

cl-itertools.lisp (file)

Function: icount START &optional STEP

start, start + step, start + 2*step, ...

Package

cl-itertools

Source

cl-itertools.lisp (file)

Function: icycle P

p0, p1, ... plast, p0, p1, ...

Package

cl-itertools

Source

cl-itertools.lisp (file)

Function: idropwhile PRED SEQ
Package

cl-itertools

Source

cl-itertools.lisp (file)

Function: ifilter PRED SEQ
Package

cl-itertools

Source

cl-itertools.lisp (file)

Function: ifilterfalse PRED SEQ
Package

cl-itertools

Source

cl-itertools.lisp (file)

Function: igroupby ITERABLE &optional KEY
Package

cl-itertools

Source

cl-itertools.lisp (file)

Function: imap FUNC &rest THINGS
Package

cl-itertools

Source

cl-itertools.lisp (file)

Function: irange &rest ARGS
Package

cl-itertools

Source

cl-itertools.lisp (file)

Function: irepeat ELEM &optional N

elem, elem, elem, ... endlessly or up to n times

Package

cl-itertools

Source

cl-itertools.lisp (file)

Function: istarmap FUNC SEQ
Package

cl-itertools

Source

cl-itertools.lisp (file)

Function: itakewhile PRED SEQ
Package

cl-itertools

Source

cl-itertools.lisp (file)

Function: izip &rest THINGS
Package

cl-itertools

Source

cl-itertools.lisp (file)

Function: izip-longest &rest THINGS
Package

cl-itertools

Source

cl-itertools.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Generic functions

Generic Function: mk-iter THING
Package

cl-itertools

Source

cl-itertools.lisp (file)

Methods
Method: mk-iter (THING vector)
Method: mk-iter (THING string)
Method: mk-iter (THING list)
Method: mk-iter (THING function)
Method: mk-iter (THING iterator)
Method: mk-iter THING

Previous: , Up: Exported definitions   [Contents][Index]

5.1.4 Conditions

Condition: stop-iteration ()
Package

cl-itertools

Source

cl-itertools.lisp (file)

Direct superclasses

error (condition)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Macros

Macro: clause-for-in-coro-1 &key (FOR VAR) (IN-CORO CORO) (WITH-ARG ARG) GENERATE
Package

cl-itertools

Source

cl-itertools.lisp (file)

Macro: clause-for-in-it-2 &key (FOR VAR) (IN-IT THING) (WITH-ARG ARG) GENERATE
Package

cl-itertools

Source

cl-itertools.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Functions

Function: i-printing-count START &optional STEP
Package

cl-itertools

Source

cl-itertools.lisp (file)

Function: parse-out-keywords KWD-LST LAMBDA-LIST

Return list (KWD1 KWD2 ... KWDn . OTHER-ARGS) collecting all keyword-looking pairs of arguments in lambda list

Package

cl-itertools

Source

cl-itertools.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Generic functions

Generic Function: i-coro OBJECT
Generic Function: (setf i-coro) NEW-VALUE OBJECT
Package

cl-itertools

Methods
Method: i-coro (ITERATOR iterator)

automatically generated reader method

Source

cl-itertools.lisp (file)

Method: (setf i-coro) NEW-VALUE (ITERATOR iterator)

automatically generated writer method

Source

cl-itertools.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.4 Classes

Class: iterator ()
Package

cl-itertools

Source

cl-itertools.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: coro
Initargs

:coro

Readers

i-coro (generic function)

Writers

(setf i-coro) (generic function)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   C   F   L  
Index Entry  Section

C
cl-itertools.asd: The cl-itertools<dot>asd file
cl-itertools/cl-itertools.lisp: The cl-itertools/cl-itertools<dot>lisp file
cl-itertools/package.lisp: The cl-itertools/package<dot>lisp file

F
File, Lisp, cl-itertools.asd: The cl-itertools<dot>asd file
File, Lisp, cl-itertools/cl-itertools.lisp: The cl-itertools/cl-itertools<dot>lisp file
File, Lisp, cl-itertools/package.lisp: The cl-itertools/package<dot>lisp file

L
Lisp File, cl-itertools.asd: The cl-itertools<dot>asd file
Lisp File, cl-itertools/cl-itertools.lisp: The cl-itertools/cl-itertools<dot>lisp file
Lisp File, cl-itertools/package.lisp: The cl-itertools/package<dot>lisp file

Jump to:   C   F   L  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   (  
C   D   F   G   I   L   M   P  
Index Entry  Section

(
(setf i-coro): Internal generic functions
(setf i-coro): Internal generic functions

C
clause-for-in-coro-1: Internal macros
clause-for-in-it-2: Internal macros
coexit!: Exported macros
collect-iter: Exported functions

D
def-launched-iter: Exported macros
defiter: Exported macros

F
Function, collect-iter: Exported functions
Function, i-printing-count: Internal functions
Function, ichain: Exported functions
Function, icompress: Exported functions
Function, icount: Exported functions
Function, icycle: Exported functions
Function, idropwhile: Exported functions
Function, ifilter: Exported functions
Function, ifilterfalse: Exported functions
Function, igroupby: Exported functions
Function, imap: Exported functions
Function, irange: Exported functions
Function, irepeat: Exported functions
Function, istarmap: Exported functions
Function, itakewhile: Exported functions
Function, izip: Exported functions
Function, izip-longest: Exported functions
Function, parse-out-keywords: Internal functions

G
Generic Function, (setf i-coro): Internal generic functions
Generic Function, i-coro: Internal generic functions
Generic Function, mk-iter: Exported generic functions

I
i-coro: Internal generic functions
i-coro: Internal generic functions
i-printing-count: Internal functions
ichain: Exported functions
icompress: Exported functions
icount: Exported functions
icycle: Exported functions
idropwhile: Exported functions
ifilter: Exported functions
ifilterfalse: Exported functions
igroupby: Exported functions
imap: Exported functions
inext: Exported macros
inext-noexit: Exported macros
inext-or-error: Exported macros
irange: Exported functions
irepeat: Exported functions
istarmap: Exported functions
itakewhile: Exported functions
izip: Exported functions
izip-longest: Exported functions

L
lambda-coro: Exported macros

M
Macro, clause-for-in-coro-1: Internal macros
Macro, clause-for-in-it-2: Internal macros
Macro, coexit!: Exported macros
Macro, def-launched-iter: Exported macros
Macro, defiter: Exported macros
Macro, inext: Exported macros
Macro, inext-noexit: Exported macros
Macro, inext-or-error: Exported macros
Macro, lambda-coro: Exported macros
Method, (setf i-coro): Internal generic functions
Method, i-coro: Internal generic functions
Method, mk-iter: Exported generic functions
Method, mk-iter: Exported generic functions
Method, mk-iter: Exported generic functions
Method, mk-iter: Exported generic functions
Method, mk-iter: Exported generic functions
Method, mk-iter: Exported generic functions
mk-iter: Exported generic functions
mk-iter: Exported generic functions
mk-iter: Exported generic functions
mk-iter: Exported generic functions
mk-iter: Exported generic functions
mk-iter: Exported generic functions
mk-iter: Exported generic functions

P
parse-out-keywords: Internal functions

Jump to:   (  
C   D   F   G   I   L   M   P  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   C   S  
Index Entry  Section

C
coro: Internal classes

S
Slot, coro: Internal classes

Jump to:   C   S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   I   P   S  
Index Entry  Section

C
cl-itertools: The cl-itertools system
cl-itertools: The cl-itertools package
cl-itertools-system: The cl-itertools-system package
Class, iterator: Internal classes
Condition, stop-iteration: Exported conditions

I
iterator: Internal classes

P
Package, cl-itertools: The cl-itertools package
Package, cl-itertools-system: The cl-itertools-system package

S
stop-iteration: Exported conditions
System, cl-itertools: The cl-itertools system

Jump to:   C   I   P   S