The associative operators :: (concatenation), &, |, ^, +, * and merge may be applied to vectors as ``reduction'' operators . For example,
&[w,x,y,z]is equivalent to
(w & x & y & z)and so on. Reduction operators may be combined with the iterated vector constructor. For example, to compute the sum of the first five squares, we could write:
+[ i*i : i = 1..5]
Note that for the non-commutative operator ::, the order of the range specification matters. For example
::[ i*i : i = 1..5]
produces [1,4,9,16,25], while
::[ i*i : i = 5..1]
produces [25,16,9,4,1]. Also note that using :: as a reduction operator makes it possible to construct a vector by repeating a pattern. For example,
::[ [0,1] : i = 1..3]
is equivalent to [0,1,0,1,0,1].
Reduction operators do not coerce their arguments to vectors. A reduction operator applied to a scalar operand has no effect. Thus, +3 = 3 (and not 2, fortunately!).