List construction
.................
- Function: make-list k
- Function: make-list k init
`make-list' creates and returns a list of K elements. If INIT is
included, all elements in the list are initialized to INIT.
Example:
(make-list 3)
=> (#<unspecified> #<unspecified> #<unspecified>)
(make-list 5 'foo)
=> (foo foo foo foo foo)
- Function: list* obj1 obj2 ...
Works like `list' except that the cdr of the last pair is the last
argument unless there is only one argument, when the result is
just that argument. Sometimes called `cons*'. E.g.:
(list* 1)
=> 1
(list* 1 2 3)
=> (1 2 . 3)
(list* 1 2 '(3 4))
=> (1 2 3 4)
(list* ARGS '())
== (list ARGS)
- Function: copy-list lst
`copy-list' makes a copy of LST using new pairs and returns it.
Only the top level of the list is copied, i.e., pairs forming
elements of the copied list remain `eq?' to the corresponding
elements of the original; the copy is, however, not `eq?' to the
original, but is `equal?' to it.
Example:
(copy-list '(foo foo foo))
=> (foo foo foo)
(define q '(foo bar baz bang))
(define p q)
(eq? p q)
=> #t
(define r (copy-list q))
(eq? q r)
=> #f
(equal? q r)
=> #t
(define bar '(bar))
(eq? bar (car (copy-list (list bar 'foo))))
=> #t