LL Push
LL_Push(LL, x)
Pushes «x» onto the front of the linked list «LL», returning a new linked list with one element more than the original «LL». «LL» itself is not changed. This function is part of the Linked list library. You can use this function to build up a collection of items when you don't know in advance how many items there will be.
To use this function, you must use Add Library... on the File menu to add the Linked list library to your model. For more on the use of linked lists, see Linked list library.
Library
Linked list library (Linked List Library.ana)
- Use File → Add Library... to add this library
Examples
This returns a linked list with one element, a
:
LL_Push(null, 'a')
This transforms a list of tokens into a linked list, but in reverse order.
Var L := [10, '+', 20, '*', '(', '5', '-', 2, '^', 3, ')', '^', 2, '-', '1'];
Var LL := null;
For x := L Do LL := LL_Push(LL, x);
LL
An algorithm that evaluates infix operators with different levels of operator precedence may want to start with tokens pushed onto a linked list in forward order.
Var L := [10, '+', 20, '*', '(', '5', '-', 2, '^', 3, ')', '^', 2, '-', '1'];
Var LL := Null;
For i := Size(L)..1 Do LL := LL_Push(LL, Slice(L, i));
LL
Enable comment auto-refresher