Doubly-linked list/Element definition: Difference between revisions
Content added Content deleted
(→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details) |
|||
Line 651: | Line 651: | ||
With that, 'cddr' can be used to access the next, and 'cadr' to access the |
With that, 'cddr' can be used to access the next, and 'cadr' to access the |
||
previous element. |
previous element. |
||
<lang PicoLisp> |
<lang PicoLisp> |
||
(de |
(de 2head (X DLst) |
||
(let L (car DLst) # Get current data list |
(let L (car DLst) # Get current data list |
||
(set DLst (cons X NIL L)) # Prepend two new cons pairs |
(set DLst (cons X NIL L)) # Prepend two new cons pairs |
||
Line 660: | Line 660: | ||
# We prepend 'not' to the list in the previous example |
# We prepend 'not' to the list in the previous example |
||
( |
(2head 'not *DLst)</lang> |
||
For output of the example data, see [[Doubly-linked list/Traversal#PicoLisp]]. |
For output of the example data, see [[Doubly-linked list/Traversal#PicoLisp]]. |
||