Skip to main content

¨ — Each

Monadic operator. Keys: Alt-1. Hanzi: 遍

f¨Y applies f to each item and collects the returned values in Y’s shape. A call that gives no result contributes ⍬. On atoms it calls f directly.

≢¨[1 2;3 4 5]      ⍝ [2 3]ₓ

X f¨Y pairs items using leading agreement.

1 2+¨10            ⍝ 11 12

On empty arguments, Each calls f once using prototypes. If that call fails, the result is empty, with prototype 0. Prototype mode permits Pick to select fill.

{100⊃"abc"}¨⍬      ⍝ ""

Other errors and explicit output remain observable in that call.

Where it can, Each calls f once on all the items together, in a batched call. The result is the same as from one call for each item.

Inverse

f¨⁻ is f⁻¨.

⊽¨⁻[2 4;6]   ⍝ [1 2;3]