for_each(fn, seq1, seq2, ...)

Apply the function fn to the corresponding elements of the sequences seq1, seq2, .... In this way, for_each is similar to map except that it does not return a sequence of results. Fn is called for its side-effect. The sequences, if finite, must be of the same length. Fn should accept as many arguments as there are sequences and should not mutate them. For_each guarantees to perform the applications in sequence over the elements from left to right.

Return void.


let (same_count = 0) 
{ for_each(^(x, y) when (x == y) same_count = same_count + 1, 
           [1, 2, 3, 4, 5], [2, 3, 3, 4, 7]); 
  same_count }
// 2

Also see:


Core Module Index | Contents