Next: , Previous: , Up: srfi list spec   [Index]

#### 2.2.5.2 Constructors

Function: cons a d

R5RS The primitive constructor. Return a newly allocated pair whose car is a and whose cdr is d. The pair is guaranteed to be different (in the sense of `eqv?`) from every existing object.

```(cons 'a '())        => (a)
(cons '(a) '(b c d)) => ((a) b c d)
(cons "a" '(b c))    => ("a" b c)
(cons 'a 3)          => (a . 3)
(cons '(a b) 'c)     => ((a b) . c)
```
Function: list object ...

R5RS Return a newly allocated list of its arguments.

```(list 'a (+ 3 4) 'c) =>  (a 7 c)
(list)               =>  ()
```
Function: xcons d a

Defined as `(lambda (d a) (cons a d))`. Of utility only as a value to be conveniently passed to higher–order procedures.

```(xcons '(b c) 'a) => (a b c)
```

The name stands for “eXchanged CONS”.

Function: cons* elt1 elt2 ...

Like `list`, but the last argument provides the tail of the constructed list, returning:

```(cons elt1 (cons elt2 (cons ... eltn)))
```

This function is called `list*` in Common Lisp and about half of the Schemes that provide it, and `cons*` in the other half.

```(cons* 1 2 3 4) => (1 2 3 . 4)
(cons* 1) => 1
```
Function: make-list n [fill]

Return 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)
```
Function: list-tabulate n init-proc

Return an n–element list. Element i of the list, where `0 <= i < n`, 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)
```
Function: list-copy flist

Copy the spine of the argument.

Function: circular-list elt1 elt2 ...

Construct a circular list of the elements.

```(circular-list 'z 'q) => (z q z q z q ...)
```
Function: iota count [start step]

Return a list containing the elements:

```(start start+step ... start+(count-1)*step)
```

The start and step parameters default to `0` and `1`, respectively. This procedure takes its name from the APL primitive.

```(iota 5) => (0 1 2 3 4)
(iota 5 0 -0.1) => (0 -0.1 -0.2 -0.3 -0.4)
```

Next: , Previous: , Up: srfi list spec   [Index]