histogram=: <: @ (#/.~) @ (i...@#@[ , I.)   NB. histogram verb from
http://www.jsoftware.com/help/dictionary/dicapdot.htm.<http://www.jsoftware.com/help/dictionary/dicapdot.htm>

a =:(_20 + (i.9)*5)           NB. intervals from minus -20 to 20 in steps of
5
b=:(+/\ 5 - ?. (20 $ 10))   NB. a simple random walk
[c=:a histogram b
0 0 0 2 8 6 2 1 1
   load 'plot'
   plot a;c

The point of the exercise for me at least is syntax, to appreciating concise
definitions, and to figure out verb trains.  I like the idea of putting lots
of concise functionality on one line, but I'm not sure that many places
would entertain the idea.

Steven
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to