manual:chapter3:lists

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
manual:chapter3:lists [2021/08/15 14:18]
claudio [Operating with Lists]
manual:chapter3:lists [2021/08/15 14:49]
claudio [Operating elements within a List]
Line 35: Line 35:
 will result in ''{ 1 2 3 4 5 6 }'' will result in ''{ 1 2 3 4 5 6 }''
  
-Other common commands that are specific for lists include (look into the command reference for details on specific commands). +Other common commands that operate on lists are:
-[[manual:chapter6:lists|Operations with Lists]] +
-{{namespace>manual:chapter6:lists&nofooter&noeditbtn}}+
  
   * ''→LIST'': Creates a list from loose objects in the stack   * ''→LIST'': Creates a list from loose objects in the stack
   * ''LIST→'': Split a list into individual objects in the stack   * ''LIST→'': Split a list into individual objects in the stack
   * ''SORT'': Sort the elements of a list   * ''SORT'': Sort the elements of a list
-  * +  * ''REVLIST'': Reverses the order of a list
  
  
 +==== Elements within a List ====
 +
 +Elements in a list can be referred to by a numeric index. The index starts at ''1'' for the first element of the list. To get an element from a list, the ''GET'' command is used:
 +<code>
 +2:                  { 11 12 13 }
 +1:                             2
 +……………………………………………………………………………………
 +GET
 +</code>
 +will result in ''12''.
 +
 +Replacing an element is done via the ''PUT'' command:
 +
 +<code>
 +3:                  { 11 12 13 }
 +2:                             2
 +1:                             3
 +……………………………………………………………………………………
 +PUT
 +</code>
 +will result in ''{ 11 3 13 }'' because the object ''3'' replaced the object at index ''2''
 +
 +Elements of a list can also be accessed from within algebraic expression (read-only) by giving the list a name (store the list in a variable using ''STO'' or ''LSTO'') and then including the index in parenthesis, much like a mathematical function.
 +For example, assuming the list ''{ 11 12 13 }'' was stored in variable ''L'', evaluating '''L(2)''' will result in ''12'' as expected.
 ==== Operating with Lists ==== ==== Operating with Lists ====
  • manual/chapter3/lists.txt
  • Last modified: 2021/08/15 14:51
  • by claudio