Well, sometimes you'd use #: (aka encode) but you'd have to know the number of 10s to put in the left argument:
n=: !100x (10&#.^:_1 n) -: (10$~1+<.10^.n) #: n 1 If you're going to resort to benchmarks, let me bring out http://www.jsoftware.com/help/release/digits10.htm , which introduced special code for "."0@": -- ts '10&#.^:_1 n' 0.000771594 385152 ts '"."0@": n' 6.99753e_6 3968 ts '(10$~1+<.10^.n) #: n' 0.000690423 373504 On Fri, Mar 7, 2014 at 2:56 PM, Murray Eisenberg <mur...@math.umass.edu>wrote: > Thanks, Roger; I suspected Base (#.) was involved; I just didn't think of > taking its inverse. > > Interestingly, although the solution using Base seems closer to the > content of the problem -- keeping things in the realm of integers instead > of going back and forth to and from strings -- on my system with J8.01, the > approach using strings is roughly 3 times slower and uses roughly 3 times > as much space. > > On Fri, 7 Mar 2014 14:15:39 -0800, Roger Hui <rogerhui.can...@gmail.com> > wrote: > > > ... > > 10&#.^:_1 x converts a number to its decimal digits. Alternatively, > > "."0":x would be shorter than what's on the video. But we quibble. > > > > 10&#.^:_1 ]!100x > > 9 3 3 2 6 2 1 5 4 4 3 9 4 4 1 5 2 6 8 1 6 9 9 2 3 8 8 5 6 2 6 6 7 0 0 4 > 9 0 > > ... > > "."0": !100x > > 9 3 3 2 6 2 1 5 4 4 3 9 4 4 1 5 2 6 8 1 6 9 9 2 3 8 8 5 6 2 6 6 7 0 0 4 > 9 0 > > ... > > —— > Murray Eisenberg mur...@math.umass.edu > Mathematics & Statistics Dept. > Lederle Graduate Research Tower phone 240 246-7240 (H) > University of Massachusetts > 710 North Pleasant Street > Amherst, MA 01003-9305 > > > > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm