Q language

#programming-language

Q is an (APL)(/apl.html).

wc in q:

Oh this is fun! Beating Decades of Optimised C (best of three)

$ time wc w.txt
 3156098 6312196 380648004 w.txt

real 0m1.358s
user 0m1.277s
sys 0m0.066s

… with one line of q (best of three):

q)\t g:{(sum[1<deltas where x]+sum[not x:max x],0),sum max x 0 1}0x0d0a2009=\:read1 `:w.txt
783
q)g
380648004i
6312196
3156098i

783msec: almost twice as fast!