manual:chapter6:lists:cmd_seq

Synopsis


Assemble a list from results of sequential procedure

Stack Diagram


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

Legend

Keyword type Command
Parallel list processing capabilities Group 7 Multiple argument, one result commands
Affected by flags None

Description


The SEQ command returns a list of results generated by repeatedly EVALuating 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 FORSTEP loop. Notice that Nindex becomes a local variable regardless of its original type.

Compatibility


SEQ is not fully equivalent to its userRPL counterpart.

In particular:

  • the program launched by SEQ operates in a protected stack environment: no elements present on the stack before SEQ is launched can be reached or altered.

Usage


Input

5:                                 'n^2'
4:                                   'n'
3:                                     1
2:                                     9
1:                                     2
…………………………………………………………………………………………………………
SEQ                                     


Output

4:                                      
3:                                      
2:                                      
1:            { '1' '9' '25' '49' '81' }
…………………………………………………………………………………………………………
                                        

Related Commands


Operations with Lists 15 2 NEW

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
  • manual/chapter6/lists/cmd_seq.txt
  • Last modified: 2021/10/02 07:55
  • by jojo1973