4 ms·
You are right, π times is the monadic "circle" function... Still trying to learn fluently all operators. And indeed, it's not a specially good example, but I do
by RBerenguel 12y ago
You are right, π times is the monadic "circle" function... Still trying to learn fluently all operators. And indeed, it's not a specially good example, but I don't have a lot of APL code written (the "nicest" being a Mandelbrot set one-liner), the "longest" being this one and a function to generate histograms, but way harder to read, since it uses quite a few operators:
∇a←n hist x
⍝ Histogram data from x in n buckets
s←x[⍋ x]
mx←¯1 ↑ s
mn←1 ↑ s
bk←mn+(⍳n)×(mx-mn)÷n
a←+/(~(↑bk)<s)
s←((↑bk)<s)/s
bk←1↓bk
LOOP:→(0=⍴bk)/END
a←a,+/(~(↑bk)<s)
s←((↑bk)<s)/s
bk←1↓bk
→LOOP
END:
∇
Not brilliant, and even at the time of writing (5 or 6 months ago) I had the feeling it may be possible to write it loopless or close enough. Variables in this one are still "global" since (even if it works) I was still checking it for possible bugs.