A special form is a kind of verb that can perform specialized operations like control flow and global modification. Special forms are generally polyadic (more than 2 arguments).
You have already seen one special form: If ($[;;..]
). We will be covering the rest of these special forms in this chapter.
Given array x
, indices y
and monadic function z
, Amend will apply z
to the elements at indices y
.
@["ABC";1 2;_:]
"Abc"
This is useful when you don't want to use assignment to modify specific elements in an array.
Same as 3 argument amend, but z
is dyadic, and u
is the second argument provided to z
.
@[2 3;0;+;4]
6 3
Similar to amend, x
is an array, but y
is a single multidimensional index, and z
is a monadic function.
Similar to 3 arguments, but with z
dyadic, and u
as the second argument.
An error handling mechanism.
x
is a function, y
is an array of arguments to x
, and z
is the function that is applied to the error message (see ch 11), if x.y
fails.
Otherwise returns x.y
. Try is most useful when you are in deeper levels of nesting in a function, and print debugging with \
(trace) is not
completely helpful.
.[+;1 2;"E:",]
3
.[+;1,`2;"E:",]
"E:'limit\n"
Splices an array z
between the indices given in y
in array x
. A very useful string function.
?["abcd";1 3;"xyz"]
"axyzd"