Difference between revisions of "LL To RArray"
m (adding doc status category stub page) |
|||
(10 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | [[Category: | + | [[Category:Linked list library functions]] |
+ | |||
+ | == LL_To_RArray(LL, indexName) == | ||
+ | Converts a linked list «LL» to an array. A new local index is created having a length equal to the number of items in the linked list, with the name «indexName» (i.e., «indexName» is a text parameter). The items in the array are in the reverse order that they appear in the linked list, which means that they are in the same order that they were pushed onto the front of the linked list. | ||
+ | |||
+ | ==Library== | ||
+ | [[Linked list library]] ([[media:Linked List Library.ana|Linked List Library.ana]]) | ||
+ | :Use [[File menu|File]] → '''Add Library...''' to add this library | ||
+ | |||
+ | == Examples == | ||
+ | :<code>Var n := 27;</code> | ||
+ | :<code>Var LL := null;</code> | ||
+ | :<code>While (n > 1) do (</code> | ||
+ | :<code>LL := LL_Push(LL, n);</code> | ||
+ | :<code>n := If Mod(n, 2) Then 3*n + 1 Else n/2</code> | ||
+ | :<code>);</code> | ||
+ | :<code>LL_To_RArray(LL, "step") →</code> | ||
+ | |||
+ | :[[image:Start_3n+1_from_27.png]] | ||
+ | ::: ⋮ | ||
+ | :[[image:End_3n+1_from_27.png]] | ||
+ | |||
+ | == See Also == | ||
+ | * [[LL_To_Array]] | ||
+ | * [[LL_Push]] | ||
+ | * [[Mod]] | ||
+ | * [[Linked list library]] | ||
+ | * [[media:Linked List Library.ana|Linked List Library.ana]] |
Latest revision as of 19:58, 24 May 2016
LL_To_RArray(LL, indexName)
Converts a linked list «LL» to an array. A new local index is created having a length equal to the number of items in the linked list, with the name «indexName» (i.e., «indexName» is a text parameter). The items in the array are in the reverse order that they appear in the linked list, which means that they are in the same order that they were pushed onto the front of the linked list.
Library
Linked list library (Linked List Library.ana)
- Use File → Add Library... to add this library
Examples
Var n := 27;
Var LL := null;
While (n > 1) do (
LL := LL_Push(LL, n);
n := If Mod(n, 2) Then 3*n + 1 Else n/2
);
LL_To_RArray(LL, "step") →
See Also
Comments
Enable comment auto-refresher