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

7.2 Construction of Lists

standard procedure: list object …

Returns a list of its arguments.

(list 'a (+ 3 4) 'c)                    ⇒ (a 7 c)
(list)                                  ⇒ ()

These expressions are equivalent:

(list obj1 obj2objN)
(cons obj1 (cons obj2 … (cons objN '()) …))
SRFI 1 procedure: make-list n [fill]

Returns an n-element list, whose elements are all the value fill. If the fill argument is not given, the elements of the list may be arbitrary values.

(make-list 4 'c)                        ⇒ (c c c c)
SRFI 1 procedure: cons* object object …

cons* is similar to list, except that cons* conses together the last two arguments rather than consing the last argument with the empty list. If the last argument is not a list the result is an improper list. If the last argument is a list, the result is a list consisting of the initial arguments and all of the items in the final argument. If there is only one argument, the result is the argument.

(cons* 'a 'b 'c)                        ⇒ (a b . c)
(cons* 'a 'b '(c d))                    ⇒ (a b c d)
(cons* 'a)                              ⇒ a

These expressions are equivalent:

(cons* obj1 obj2objN-1 objN)
(cons obj1 (cons obj2 … (cons objN-1 objN) …))
SRFI 1 procedure: list-tabulate k init-proc
obsolete procedure: make-initialized-list k init-proc

Returns a k-element list. Element i of the list, where 0 <= i < k, is produced by (init-proc i). No guarantee is made about the dynamic order in which init-proc is applied to these indices.

(list-tabulate 4 values) => (0 1 2 3)
SRFI 1 procedure: list-copy list

Returns a newly allocated copy of list. This copies each of the pairs comprising list. This could have been defined by

(define (list-copy list)
  (if (null? list)
      (cons (car list)
            (list-copy (cdr list)))))
SRFI 1 procedure: iota count [start [step]]

Returns a list containing the elements

(start start+stepstart+(count-1)*step)

Count must be an exact non-negative integer, while start and step can be any numbers. The start and step parameters default to 0 and 1, respectively.

(iota 5) ⇒ (0 1 2 3 4)
(iota 5 0 -0.1) ⇒ (0 -0.1 -0.2 -0.3 -0.4)
standard procedure: vector->list vector [start [end]]
obsolete procedure: subvector->list vector start end

Returns a newly allocated list of the elements of vector between start inclusive and end exclusive. The inverse of vector->list is list->vector.

(vector->list '#(dah dah didah))        ⇒ (dah dah didah)

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