Next: , Previous: , Up: loops comprehensions   [Index]


1.16.2.2 List accumulator loops

Syntax: list-ec ?qualifier ... expression

The list of values obtained by evaluating expression once for each binding in the sequence defined by the qualifiers. If there are no qualifiers the result is the list with the value of expression.

(list-ec                ;no qualifiers
  1)
⇒ (1)

(list-ec (:range i 4)   ;i from 0 to 3
  i)
⇒ (0 1 2 3)

(list-ec (:range n 3)
         (:range k (+ n 1))
  (list n k))
⇒ ((0 0)
    (1 0) (1 1)
    (2 0) (2 1) (2 2))
Syntax: append-ec ?qualifier ... expression

The list obtained by appending all values of expression, which must all be lists. Think of it as:

(apply append (list-ec ?qualifier ... expression))

Examples:

(append-ec              ;no qualifiers
  '(a b))
⇒ (a b)

(append-ec (:range i 0) ;loops zero times
  '(a b))
⇒ '()

(append-ec (:range i 1)
  '(a b))
⇒ (a b)

(append-ec (:range i 2)
  '(a b))
⇒ '(a b a b)