Labbekak
Labbekak

Reputation: 527

J, the unfindable verb

1 0 0 1 verb 1 2 3 4
  result:1 4

The verb drops the items from the list on the right that have a 0 in the list on the left. I can remember seeing this verb in the Vocabulary but I can't find it again. Does anybody know this verb?

Upvotes: 3

Views: 159

Answers (1)

MPelletier
MPelletier

Reputation: 16697

It's #.

Explanation: Such verbs (1 or 2 symbols, rarely 3) are called primitives. The # primitive is called Tally as a monad (effectively tallies the items, returning the count on the first dimension), and Copy as a dyad, where it copies the right arguments as many times as indicated on the left argument. Of course, in this case, your right and left elements must be the same length (or that one of them is scalar if the other is not).

Example:

   1 0 0 1 # 1 2 3 4
1 4

Upvotes: 6

Related Questions