RosettaCodeData/Task/Singly-linked-list-Element-definition/Pop11/singly-linked-list-element-definition-1.pop11
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

15 lines
408 B
Text

;;; Use shorthand syntax to create list.
lvars l1 = [1 2 three 'four'];
;;; Allocate a single list node, with value field 1 and the link field
;;; pointing to empty list
lvars l2 = cons(1, []);
;;; print first element of l1
front(l1) =>
;;; print the rest of l1
back(l1) =>
;;; Use index notation to access third element
l1(3) =>
;;; modify link field of l2 to point to l1
l1 -> back(l2);
;;; Print l2
l2 =>