Doubly-linked list/Element insertion: Difference between revisions

Added PicoLisp
(→‎{{header|AutoHotkey}}: moved to new url)
(Added PicoLisp)
Line 375:
/* Points the next node to the new one. */
</lang>
 
=={{header|PicoLisp}}==
This works with the structures described in
[[Doubly-linked list/Definition#PicoLisp]] and
[[Doubly-linked list/Element definition#PicoLisp]].
<lang PicoLisp># Insert an element X at position Pos
(de 2insert (X Pos DLst)
(let (Lst (nth (car DLst) (dec (* 2 Pos))) New (cons X (cadr Lst) Lst))
(if (cadr Lst)
(con (cdr @) New)
(set DLst New) )
(if (cdr Lst)
(set @ New)
(con DLst New) ) ) )
 
(setq *DL (2list 'A 'B)) # Build a two-element doubly-linked list
(2insert 'C 2 *DL) # Insert C at position 2</lang>
For output of the example data, see [[Doubly-linked list/Traversal#PicoLisp]].
 
=={{header|Pop11}}==
Anonymous user