Difference between revisions of "LL Push"

 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
[[Category:Linked list library functions]]
 +
 
== LL_Push(LL, x) ==
 
== 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.
 
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]].
 
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]] ([[media:Linked List Library.ana|Linked List Library.ana]])
 +
:Use [[File menu|File]] → '''Add Library...''' to add this library
  
 
== Examples ==
 
== Examples ==
Line 20: Line 26:
 
:<code>LL</code>
 
:<code>LL</code>
  
== See also ===
+
== See also ==
 
* [[Linked list library]]
 
* [[Linked list library]]
 +
* [[media:Linked List Library.ana|Linked List Library.ana]]
 
* [[LL_To_RArray]]
 
* [[LL_To_RArray]]
 
* [[LL_To_Array]]
 
* [[LL_To_Array]]

Latest revision as of 19:58, 24 May 2016


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 FileAdd 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

See also

Comments


You are not allowed to post comments.