NB. Generate multiple sets of 6 random integers from 1 to 6:
]m=:5 6$>:?30#6
2 2 1 6 6 5
6 5 6 6 6 6
3 4 3 3 5 2
1 2 6 4 3 1
5 6 1 3 2 4
NB. Use dyadic function oc (occurrence count) to calculate the occurrence
counts of
NB. the integers in the right (y) argument, using the reference integer set
in the left {x} argument:
(>:i.6) oc m
1 2 0 0 1 2
0 0 0 0 1 5
0 1 3 1 0 1
2 1 1 1 0 1
1 1 1 1 1 1
NB. If an integer in the x noun is not in the y noun, the result of oc will
be zero in that place.
NB. If there is an integer in the y noun that is not in the x noun, it is
ignored.
NB. What is oc? The verb 'oc' should allow for any length reference set (x
argument),
NB. any width right argument, and any number of items (rows)
Skip
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm