F

F. Parallel Processing with Lists

Parallel processing is the idea that, generally, if a command can be applied to one or more individual arguments, then it can also be extended to be applied to one or more sets of arguments. (Note: some examples assume approximate mode.)

Some examples:

 5 INV returns .2, so { 4 5 8 } INV returns { .25 .2 .125 }.

 4 5 * returns 20, so { 4 5 6 } { 5 6 7 } * returns { 20 30 42 }, and { 4 5 6 } 5

*returns { 20 25 30 }.

General rules for parallel processing

As a rule-of-thumb, a given command can use parallel list processing if all the following are true:

The command checks for valid argument types. Commands that apply to all object types, such as DUP, SWAP, ROT, and so forth, do not use parallel list processing.

The command takes exactly one, two, three, four, or five arguments, none of which may itself be a list. Commands that use an indefinite number of arguments (such as →LIST) do not use parallel list processing.

The command isn’t a programming branch command (IF, FOR, CASE, NEXT, and so forth).

The remainder of this appendix describes how the many and various commands available on the calculator are grouped with respect to parallel processing.

Group 1: Commands that cannot parallel process

A command must take arguments before it can parallel process, since a zero-argument command (such as RAND, VARS, or REC) has no arguments with which to form a group.

Group 2: Commands that must use DOLIST to parallel process

This group of commands cannot use parallel processing directly, but can be “coerced” into it using the DOLIST command (see Using D later in this appendix). This group consists of several subgroups:

Stack manipulation commands. A stack manipulation command cannot parallel process because the stack is manipulated as a whole and list objects are treated the same as any other object. Stack commands (such as DROP) that take level 1 arguments will not accept level 1 list arguments.

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, →STR converts the entire list object to a string rather than converting each individual element, and the == command tests the level 1 object against the level 2 object regardless of the objects’ types.

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 DOLIST command. For example, { { 1 2 3 } { 4 5 6 } } « œLIST » DOLIST returns { 6 120 }.

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 DOLIST.

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 } RANM will generate a random

Parallel Processing with Lists F-1