Notice the special code for ?...@$

R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: [email protected] [mailto:programming-
> [email protected]] Namens Marshall Lochbaum
> Verzonden: maandag 30 augustus 2010 22:38
> Aan: 'Programming forum'
> Onderwerp: Re: [Jprogramming] Splitting an integer into its digits
> 
> For the record on all these:
>    a=. (-? 1000$100) |.!.0"0 1 ?1000 100000$10
>    6!:2 '<@(#~ [: >&0 +/\)"1 a'
> 2.73302
>    6!:2 '<@(#~ [: +./\ ~:&0)"1 a'
> 1.90478
>    6!:2 '<@(}.~ [: i.&1 ~:&0)"1 a'
> 1.35619
>    6!:2 '<@(}.~ 0&(i.&1@:~:))"1 a'
> 1.15012
> 
> Where boxing is required to keep from re-padding results (which is quite
> time-consuming).
> 
> Marshall
> 
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Henry Rich
> Sent: Sunday, August 29, 2010 10:45 PM
> To: Programming forum
> Subject: Re: [Jprogramming] Splitting an integer into its digits
> 
> Coming in late to this thread.
> 
> i.&1@:~:   is backed by special code, so this could be written as
> 
> }.~   0&(i.&1@:~:)
> 
> 
> Henry Rich
> 
> 
> On 8/29/2010 8:36 PM, Marshall Lochbaum wrote:
> > Oh, or
> > }.~ [: i.&1 ~:&0
> > That should be really fast.
> >
> > Marshal
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of gary ng
> > Sent: Sunday, August 29, 2010 7:55 PM
> > To: Programming forum
> > Subject: Re: [Jprogramming] Splitting an integer into its digits
> >
> > On Sun, Aug 29, 2010 at 11:49 AM, Alex Gian<[email protected]>
> > wrote:
> >> Thanks for the tip about the precomputed values, I should have done
> >> it to be fair, since I use it in my Perl comparison, but I forgot as
> >> I'm concentrating on learning J here...  It does indeed bring a big
> >> speedup, although I'm pretty sure that my integer-splitting method is
> >> a quite a bit faster than the one you suggest.
> >>
> >> I like the idea of using rank 1 rather than transpose.
> >>
> >> Anyway, fastest I've got so far, and quite an acceptable result to me
> >> would now be specialX -. = +/"1@({&f)@(10&#.inv) if only I could sort
> >> out the leading zero problem.  Your
> >
> > not sure if this is an efficient way to do a 'dropWhile (=0)'
> >
> > (#~[:>&0+/\) 0 1 2 3
> > =>  1 2 3
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to