RosettaCodeData/Task/Doubly-linked-list-Definition/Mathematica/doubly-linked-list-definition.math
2023-07-01 13:44:08 -04:00

7 lines
282 B
Text

ds = CreateDataStructure["DoublyLinkedList"];
ds["Append", #] & /@ {1, 5, 7, 0, 3, 2};
ds["Prepend", 9];
ds["Append", 4];
(* This is adding at the end and then swap to insert in to the middle: *)
ds["Append", 14]; ds["SwapPart", Round[ds["Length"]/2], ds["Length"]];
ds["Elements"]