q) di:group li:1 2 3 3 2 1
1| 0 5
2| 1 4
3| 2 3
How having di get li? Is there better than {@[x;y;:;z]}/[(sum count each di)#0N;value di;key di] ?
q) di:group li:1 2 3 3 2 1
1| 0 5
2| 1 4
3| 2 3
How having di get li? Is there better than {@[x;y;:;z]}/[(sum count each di)#0N;value di;key di] ?
one way
q)di:group li:10000000?10000
q)li~(where count each di)iasc raze di
1b
q)\ts (where count each di)iasc raze di
1401 402784640
q)\ts {@[x;y;:;z]}/[(sum count each di)#0N;value di;key di]
121931 402670528
It is great. I used to apply where function to binary lists and forgot his affect for integer lists and dictionaries. Thanks for reminding me.
another way, ie amend can be okay if the over is avoided
q)\ts (where count each di)iasc raze di
3440 402784576
q)\ts @[count[r]#first key di;r:raze di;:;where count each di]
497 402653840