One Minute One-liners for the curious: https://www.youtube.com/@1minute1liners
In this YouTube short, I explain how to create a fast discrete histogram function that can count all manner of datatypes in PARI, including finite field elements, polynomials, polymods, rational functions, etc. The one-liner of note is:
SX=vecsort(X,cmp);
Below are the functions discretehist.gp and its test code tdiscretehist.gp, as well at inthist.gp and the test code tinthist.gp
The 7 support functions in tdiscretehist.gp are as follows:
pause(t) - wait for t seconds
false(N) - create vector of N zeros
binequal(a,b) - create binary vector indicating where vectors a and b are equal
binrand(N) - create binary random vector
binrand0(N) - create binary random vector not all zero
vecidiff(a) - crete binary vector indicating where values change
idxzero(a,{b=0}) - create index vector indicating where a==b