Lisp provides the function list, that as the name indicates, creates a new list with the elements that it is provided. Our original list first-beat contains events sorted from lowest to highest voice. To construct a new list with only the outer voices from first-beat we could write:
(list (car (last first-beat)) (first first-beat))
((0 72 1000 1 60) (0 60 1000 4 60))
Some situations may require an insertion of an event into a previously existing list of events. The function cons (“constructor”) takes two arguments, an atom and a list, and returns one list, as in the following example, where the attack time is re-inserted back into the event:
> (cons 0 '(72 1000 1 60))
(0 72 1000 1 60)
A related function to cons is append that accepts two lists as arguments and
returns one:
> (append '((0 60 1000 4 60)) '((0 64 1000 3 60)))
((0 60 1000 4 60) (0 64 1000 3 60))
(list (car (last first-beat)) (first first-beat))
((0 72 1000 1 60) (0 60 1000 4 60))
Some situations may require an insertion of an event into a previously existing list of events. The function cons (“constructor”) takes two arguments, an atom and a list, and returns one list, as in the following example, where the attack time is re-inserted back into the event:
> (cons 0 '(72 1000 1 60))
(0 72 1000 1 60)
A related function to cons is append that accepts two lists as arguments and
returns one:
> (append '((0 60 1000 4 60)) '((0 64 1000 3 60)))
((0 60 1000 4 60) (0 64 1000 3 60))