Go to the first, previous, next, last section, table of contents.


nconc

Function: nconc { list list -> list }
file: 10-C-lists.muf
package: muf
status: alpha

The MUF nconc function destructively joins two lists: The last cons cell in the first list is changed to point to the first cons cell in the second list:

Stack:
[ 'a' 'b' ]l [ 'c' 'd' ]l nconc --> list
Stack:
list first  list second  list third  list fourth
Stack: 'a' 'b' 'c' 'd'

This looks much like the append function (see section append) but is much more dangerous, since it modifies an existing list instead of constructing a new one: nconc is an efficiency hack to avoid allocating new list cells. Use it only if you really need to.

The name comes from CommonLisp: 'conc' for 'concatenate', prefixed by the 'n' which signals a dangerous function modifying existing lists. (Think of as as n-for-nuke.)


Go to the first, previous, next, last section, table of contents.