What's a more concise way to count the number of times an element occurs in a list in J? -


Here I have done it (possibly simpler):

 count =: 4: ' In other words, if I have the  4 count 3 4 4 3 4 7 9  result, then  3 (# ~ = & x) y 1 " 

, Because the given list contains 4 3 three times.

It works perfectly, but I wonder what else short for this phrase The method provides.

When I do this, knowing that I only I have a list and I am not a matrix, for many searches in the I list: count =: 4: '+ / x = y'

Your method copies are copies only on elements which are equal to x , Then the result is estimated to be understood by people for equality is a low operation.


Comments