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
