3 ms·
Most people have difficulty with the fact that an array expression can very compactly represent some powerful functions. For example, (+/*)\: is matrix mult
by bakul 8y ago
Most people have difficulty with the fact that an array expression can very compactly represent some powerful functions. For example,
(+/*)\:
is matrix multiplication. The following computes the transitive closure of a binary relation (represented as a boolean square matrix):
{x|x(|/&)\:x}
Its core has a similar "shape" as matrix multiplication:
(|/&)\:
So in a sense variable names don't matter all that much! To grok this code you have to stop thinking in terms of item at a time operations and start thinking of operations over collection of items. If you know how to write unix shell pipelines you are already somewhat familiar with this paradigm except that a shell doesn't provide most of the more useful features of array languages!