by Veedrac · 1y ago · 0 comments
Is this... just to be clever? Why not
(!x)=/:!x
aka. the identity matrix is defined as having ones on the diagonal? Bonus points AI will understand the code better. q)x:1000
q)\t:1000 sum (til x)=/:(til x)
889
q)\t:1000 sum (til x)=/:(til x)
871
q)\t:1000 sum (2#x)#1,x#0
602
q)\t:1000 sum (2#x)#1,x#0
599
upd: in ngn/k, situation is opposite ;-oSome brief notations make sense. Consider, say, einsum: "ij->ji" elegantly expresses a whole operation in a way that exposes the underlying symmetry of the domain. I don't think q's line noise style (or APL for that matter) is similarly exposing any deeper structure.