? ?input_index
(?input_index
)
Outputs the value of the current iteration.
The meaning of ?
depends on the context from which it is run and its full meaning is documented in the procedures which provide this context.
It is typically usable from contexts that iterate over a list of values and it outputs current value.
To support iteration contexts where each iteration has multiple values, ?
accepts an optional input which selects the value of the current iteration to output.
The index of the value to select typically follows the ?
without any space in between, for example as ?2
, but it can also be given as a parenthesized expression (? 2)
.
The latter form is necessary when the index of the value to select is not known in advance (for example, if the index is stored in a variable).
?
is a short for ?1
, which is a short for (? 1)
.
This is true even for simple iteration contexts where each iteration has only one value.
APPLY enables the use of ?
.
Below you can see ?
at work in its simplest form.
This should give you an idea of how to use APPLY to write your own procedures which can input caller-supplied templates that support ?
.
SHOW APPLY [?1] [a b c]
aSHOW APPLY [?2] [a b c]
bSHOW APPLY [?3] [a b c]
c
?
has no meaning outside of a context which is designed specifically for its use.
The following example shows how to use ?
within the context of FILTER to remove consonants from a word.
SHOW FILTER [MEMBERP ? "aeiou] "elephant
eea
The next example shows an iteration context where each iteration has multiple values to select. It creates a single list by concatenating the corresponding members of two lists.
SHOW (MAP [WORD ?1 ?2] [a b c] [x y z])
[ax by cz]
CASCADE |
CASCADE.2 |
CROSSMAP |
FIND |
FOREACH |
MAP |
MAP.SE |