cancel
Showing results for 
Search instead for 
Did you mean: 

Count items from a dynamic list

hzadonis369
New Contributor II

Hi, Masters:

  Say I have a list contains dynamic sym variables: 

    `a`b`a`b`c`d`c`b`a...

  How can I count each sym and get an output such as:

    `a:4

    `b:3

    `c:2

    `d:1

1 ACCEPTED SOLUTION

hzadonis369
New Contributor II

q)lt: `a`b`a`b`c`d`c`b`a

q)group lt
a| 0 2 8
b| 1 3 7
c| 4 6
d| ,5

q)count each group lt
a| 3
b| 3
c| 2
d| 1

Seems not difficult. Any other method?

View solution in original post

1 REPLY 1

hzadonis369
New Contributor II

q)lt: `a`b`a`b`c`d`c`b`a

q)group lt
a| 0 2 8
b| 1 3 7
c| 4 6
d| ,5

q)count each group lt
a| 3
b| 3
c| 2
d| 1

Seems not difficult. Any other method?