Assemble a list from results of sequential procedure
Input Stack | Output Stack | |||||
---|---|---|---|---|---|---|
Pexec | Nindex | Numstart | Numend | Numincr | → | Lresults |
Aexec | Nindex | Numstart | Numend | Numincr | → | Lresults |
Nexec | Nindex | Numstart | Numend | Numincr | → | Lresults |
Level 5 | Level 4 | Level 3 | Level 2 | Level 1 | → | Level 1 |
The SEQ
command returns a list of results generated by repeatedly EVAL
uating a program, a symbolic object or an identifier using Nindex over the range Numstart to Numend, in increments of Numincr.
The action of SEQ
for arbitrary inputs can be predicted exactly from this equivalent program:
Numstart Numend FOR 'Nindex' Pexec EVAL Numincr STEP n → LIST
where n
is the number of new objects left on the stack by the FOR
… STEP
loop. Notice that Nindex becomes a local variable regardless of its original type.
SEQ
is not fully equivalent to its userRPL counterpart.
In particular:
SEQ
operates in a protected stack environment: no elements present on the stack before SEQ
is launched can be reached or altered.Input
5: 'n^2' 4: 'n' 3: 1 2: 9 1: 2 ………………………………………………………………………………………………………… SEQ
Output
4: 3: 2: 1: { '1' '9' '25' '49' '81' } …………………………………………………………………………………………………………
Command | Short Description | |
---|---|---|
→LIST | Assemble a list from its elements | |
LIST→ | Split a list into its elements | |
DOLIST | Do a procedure with elements of lists | CHANGED |
DOSUBS | Do a procedure on a subset of a list | CHANGED |
MAP | Do a procedure on each element of a list, recursively | |
MAPLIST→ | Do a procedure on each element recursively, return individual elements | NEW |
STREAM | Do a procedure on consecutive elements of a list | |
ΔLIST | First differences on the elements of a list | |
ΣLIST | Sum of all elements in a list | CHANGED |
ΠLIST | Product of all elements in a list | CHANGED |
ADD | Concatenate lists and/or elements | CHANGED |
SORT | Sort elements in a list | |
REVLIST | Reverse the order of elements in a list | |
ADDROT | Add elements to a list, keep only the last N elements | NEW |
SEQ | Assemble a list from results of sequential procedure |