paths ← item ##.in array ⍝ Locations of item ⍺ in array ⍵.
[in] returns a vector of the "pick-paths" of the locations of [item] in [array].
Each item of the result is a vector, which can be used to select the [item] from
the [array] using primitive function pick (⊃).
Examples:
1 in 3 1 4 1 5 ⍝ vector of path vectors
┌─┬─┐
│2│4│
└─┴─┘
'o' in 'hello' 'world' ⍝ locations of 'o' characters
┌───┬───┐
│1 5│2 2│
└───┴───┘
'o'{'⌽' @(⍺ in ⍵)⊢⍵} 'hello' 'world' ⍝ substitution
┌─────┬─────┐
│hell⌽│w⌽rld│
└─────┴─────┘
'o'in ⍪'hello' 'world' ⍝ paths in matrix ⍵
┌───────┬───────┐
│┌───┬─┐│┌───┬─┐│
││1 1│5│││2 1│2││
│└───┴─┘│└───┴─┘│
└───────┴───────┘
avg←(sum←+⌿)÷≢ ⍝ functions for average and sum
⎕cr'avg' ⍝ character rep.
┌──┬─┬─┐
│+⌿│÷│≢│
└──┴─┴─┘
(⊂'sum')@((⎕cr'sum')in ⎕cr'avg')⊢⎕cr'avg' ⍝ name for value, see →defs←
┌───┬─┬─┐
│sum│÷│≢│
└───┴─┴─┘
See also: defs
Back to: contents
Back to: Workspaces