The benchmarks got me thinking: which are the most efficient functions that depend on the value of each atom of an array? The curious wording of the question is to rule out things like #x . Perhaps I need to say "... that depends on inspecting the value of each atom of an array", to rule out <x . Anyway:
x=: 1e6 ?...@$ 0 10 timer '3!:1 x' 0.0178869 10 timer 'x+x' 0.0176178 10 timer '+/x' 0.00192966 10 timer '+/\x' 0.0177407 I am not interested in the timing difference between +/ and >./ . ----- Original Message ----- From: Roger Hui <[email protected]> Date: Wednesday, April 7, 2010 8:25 Subject: Re: [Jprogramming] lines in display To: Programming forum <[email protected]> > As already mentioned in this thread, 3!:1 by itself is > very efficient (time and space), and is lossless > (represents its argument with perfect fidelity). > For example: > > x=: 1e6 ?...@$ 0 > ts '3!:1 x' > 0.0228582 8.38938e6 > ts 'x+x' > 0.0164448 8.38918e6 > > x -:!.0 (3!:2) (3!:1) x > 1 > > > > ----- Original Message ----- > From: Don Guinn <[email protected]> > Date: Wednesday, April 7, 2010 5:55 > Subject: Re: [Jprogramming] lines in display > To: Programming forum <[email protected]> > > > Shouldn't try to send messages when I'm tired. Should have > said in > > conjunction with 5!:1. But when I did that a while back I was > > concerned with > > loss of precision for nouns, not efficiency. These messages > made > > me realize > > that this approach may not be very efficient for sending nouns > > as this > > approach includes a conversion to character. Maybe I need to > > make it a > > little smarter and handle nouns without going through 5!:1. > > > > On Wed, Apr 7, 2010 at 4:08 AM, Zsbán Ambrus > > <[email protected]> wrote: > > > > > On Wed, Apr 7, 2010 at 4:19 AM, Roger Hui > <[email protected]> > > wrote:> > They can handle the _representations_ of non-nouns, > > > > (such as 3!:1 (5!:1)<'nameofverb'), but not those > > > > non-nouns per se. > > > > > > Right, 5!:1 followed by 3!:1 is how the irc bots (both > > jevalbot and > > > the buubot jsess macro) saves the variables between lines of > > execution> -- they don't keep the J process open, and can > > duplicate a session. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
