Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
manual:chapter5:listproc [2019/10/02 14:45] jojo1973 Second pass at parallel list processing |
manual:chapter5:listproc [2019/10/18 13:56] jojo1973 [Group 9: Quirky commands] Fixed examples |
||
---|---|---|---|
Line 24: | Line 24: | ||
* **Commands that operate on a list as a whole.** Certain commands accept lists as arguments but treat them no differently than any other data object. They perform their function on the object as a whole without respect to its elements. For example, '' | * **Commands that operate on a list as a whole.** Certain commands accept lists as arguments but treat them no differently than any other data object. They perform their function on the object as a whole without respect to its elements. For example, '' | ||
* **List manipulation commands.** List manipulation commands will not parallel process since they operate on list arguments as lists rather than as sets of parallel data. However, a list manipulation command can be forced to parallel process lists of lists by using the '' | * **List manipulation commands.** List manipulation commands will not parallel process since they operate on list arguments as lists rather than as sets of parallel data. However, a list manipulation command can be forced to parallel process lists of lists by using the '' | ||
- | { { 1 2 3 } { 4 5 6 } } | + | 3: { { 1 2 3 } { 4 5 6 } } |
- | 1 | + | 2: 1 |
- | « ΠLIST » | + | 1: « ΠLIST » |
+ | …………………………………………………………………………………… | ||
DOLIST | DOLIST | ||
</ | </ | ||
* **Other commands that have list arguments.** Because a list can hold any number of objects of any type, it is commonly used to hold a variable number of parameters of various types. Some commands accept such lists, and because of this are insensitive to parallel processing, except by using '' | * **Other commands that have list arguments.** Because a list can hold any number of objects of any type, it is commonly used to hold a variable number of parameters of various types. Some commands accept such lists, and because of this are insensitive to parallel processing, except by using '' | ||
* **Index-oriented commands.** Many array commands either establish the size of an array in rows and columns or manipulate individual elements by their row and column indices. These commands expect these row and column indices to be real number pairs collected in lists. For example, < | * **Index-oriented commands.** Many array commands either establish the size of an array in rows and columns or manipulate individual elements by their row and column indices. These commands expect these row and column indices to be real number pairs collected in lists. For example, < | ||
- | { 3 4 } | + | 1: { 3 4 } |
+ | …………………………………………………………………………………… | ||
RANM | RANM | ||
</ | </ | ||
* **Program control commands.** Program control structures and commands do no perform parallel processing and cannot be forced to do so. However, programs containing these structures can be made to parallel process by using '' | * **Program control commands.** Program control structures and commands do no perform parallel processing and cannot be forced to do so. However, programs containing these structures can be made to parallel process by using '' | ||
- | { 1 2 3 4 5 6 } | + | 3: { 1 2 3 4 5 6 } |
- | 1 | + | 2: 1 |
- | « IF | + | 1: « IF |
- | DUP 3 ≤ | + | |
- | THEN | + | |
- | DROP | + | |
- | END | + | |
- | » | + | |
+ | …………………………………………………………………………………… | ||
DOLIST | DOLIST | ||
</ | </ | ||
- | ==== Group 3: commands | + | ==== Group 3: Commands |
- | FIXME | + | |
- | + | ||
- | ==== Group 4: ADD and + ==== | + | |
FIXME | FIXME | ||
- | ==== Group 5: Commands that set modes / states ==== | + | ==== Group 4: Commands that set modes / states ==== |
Commands that store values in system-specific locations so as to control certain modes and machine states can generally be used to parallel process data. The problem is that each successive parameter in the list cancels the setting established by the previous parameter. For example, < | Commands that store values in system-specific locations so as to control certain modes and machine states can generally be used to parallel process data. The problem is that each successive parameter in the list cancels the setting established by the previous parameter. For example, < | ||
- | { 1 2 3 4 5 } | + | 1: { 16 32 48 } |
- | FIX</ | + | …………………………………………………………………………………… |
- | 5 | + | SETPREC</ |
- | FIX | + | 1: 48 |
+ | …………………………………………………………………………………… | ||
+ | SETPREC | ||
</ | </ | ||
- | ==== Group 6: One-argument, | + | ==== Group 5: One-argument, |
These commands are the easiest to use with parallel processing. Simply provide the command with a list of arguments instead of the expected single argument. Some examples: | These commands are the easiest to use with parallel processing. Simply provide the command with a list of arguments instead of the expected single argument. Some examples: | ||
- | * < | + | * < |
+ | 1: { 1 -2 3 -4 } | ||
+ | …………………………………………………………………………………… | ||
ABS | ABS | ||
</ | </ | ||
* < | * < | ||
- | DEG | + | 1: |
- | { 0 30 60 90 } | + | …………………………………………………………………………………… |
SIN | SIN | ||
- | </ | + | </ |
* < | * < | ||
- | { 1 A ' | + | 1: { 1 'A' |
+ | …………………………………………………………………………………… | ||
INV | INV | ||
</ | </ | ||
- | ==== Group 7: Two-arguments, | + | ==== Group 6: Two-arguments, |
Two-argument commands can operate in parallel in any of three different ways: | Two-argument commands can operate in parallel in any of three different ways: | ||
Line 84: | Line 89: | ||
In the first form, parallel elements are combined by the command: < | In the first form, parallel elements are combined by the command: < | ||
- | { 1 2 3 } | + | 2: { 1 2 3 } |
- | { 4 5 6 } | + | 1: { 4 5 6 } |
+ | …………………………………………………………………………………… | ||
% | % | ||
</ | </ | ||
In the second form, the level 1 object is combined with each element in the level 2 list in succession: < | In the second form, the level 1 object is combined with each element in the level 2 list in succession: < | ||
- | { 1 2 3 } | + | 2: { 1 2 3 } |
- | 30 | + | 1: |
+ | …………………………………………………………………………………… | ||
%CH | %CH | ||
</ | </ | ||
In the third form, the level 2 object is combined with each element of the level 1 list in succession: < | In the third form, the level 2 object is combined with each element of the level 1 list in succession: < | ||
- | 50 | + | 2: |
- | { 1 2 3 } | + | 1: { 1 2 3 } |
+ | …………………………………………………………………………………… | ||
%T | %T | ||
</ | </ | ||
- | ==== Group 8: Multiple-argument, | + | ==== Group 7: Multiple-argument, |
Commands that take multiple (3, 4, or 5) arguments can perform parallel processing only if all arguments are lists. For example, '' | Commands that take multiple (3, 4, or 5) arguments can perform parallel processing only if all arguments are lists. For example, '' | ||
- | ==== Group 9: Multiple-result commands ==== | + | ==== Group 8: Multiple-result commands ==== |
Any command that allows parallel processing, but produces multiple results from its input data, will return its results as a single list. For example,< | Any command that allows parallel processing, but produces multiple results from its input data, will return its results as a single list. For example,< | ||
- | { 1 2 3 } | + | 2: { 1 2 3 } |
- | { 4 5 6 } | + | 1: { 4 5 6 } |
+ | …………………………………………………………………………………… | ||
R→C | R→C | ||
+ | </ | ||
+ | 1: { (1, 4) (2, 5) (3, 6) } | ||
+ | …………………………………………………………………………………… | ||
C→R | C→R | ||
</ | </ | ||
Line 124: | Line 136: | ||
» | » | ||
</ | </ | ||
+ | |||
Taking '' | Taking '' | ||
- | 2 | + | 2: { 1 4 2 5 3 6 } |
+ | 1: 2 | ||
+ | …………………………………………………………………………………… | ||
UNMIX | UNMIX | ||
</ | </ | ||
- | ==== Group 10: Quirky commands ==== | + | ==== Group 9: Quirky commands ==== |
A few commands behave uniquely with respect to parallel processing: | A few commands behave uniquely with respect to parallel processing: | ||
* '' | * '' | ||
- | { 1 3 } | + | 1: { 1 3 } |
+ | …………………………………………………………………………………… | ||
DELALARM | DELALARM | ||
</ | </ | ||
- | { 3 1 } | + | 1: { 3 1 } |
+ | …………………………………………………………………………………… | ||
DELALARM | DELALARM | ||
</ | </ | ||
Line 146: | Line 163: | ||
* Level 1 must contain a command, a program object, or the name of a variable that contains a command or program object. | * Level 1 must contain a command, a program object, or the name of a variable that contains a command or program object. | ||
- | * Level 2 must contain an argument count unless the level 1 object is a command that accepts parallel processing, or a user-defined function. In these special cases, level 2 contains the first of the list arguments. FIXME | + | * Level 2 must contain an argument count. |
- | * If level 2 was the argument count, then level 3 is the first of the argument lists. Otherwise, levels 2 through | + | * Level 3 and on are the argument lists. |
As an example, the following program takes three objects from the stack, tags them with the names '' | As an example, the following program takes three objects from the stack, tags them with the names '' |