3 ms·
The main difference, in Common Lisp at least, is that push modifies the list to add the new cell. Cons returns a new list with the cell added so the old list re
by mtreis86 4y ago
The main difference, in Common Lisp at least, is that push modifies the list to add the new cell. Cons returns a new list with the cell added so the old list remains untouched.
CL-USER> (let ((list (list 1 2 3 4)))
(cons 5 list)
list)
(1 2 3 4)
CL-USER> (let ((list (list 1 2 3 4)))
(push 5 list )
list)
(5 1 2 3 4)
- hayley-patton 4y agoCareful - push is a macro which modifies the value bound to "list", but doesn't modify any of the cons cells in that list.
- mtreis86 4y agoSo no rplaca/d, just cons and setf?
- hayley-patton 4y agoRight.