The string approach seems more efficient in the long run, I guess.
The human eye makes no difference between the string and the corresponding 
number, so why would I?

I prefer Hui's solution with a slight amendment on f and preprocessing the 
input number:

f=: ; @: (*:&.".&.>)
f^:(i.10) ": 9

R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: Programming <[email protected]>
> Namens Ben Gorte
> Verzonden: dinsdag 14 mei 2019 03:40
> Aan: [email protected]
> Onderwerp: Re: [Jprogramming] Seqfan problem
> 
> I can make it a few characters shorter and avoid the logarithm, but the main
> idea is still the same:
> 
> 
>  g =: (#.~10x^(1+>&9))@:*:@:(10&#.^:_1)
> 
> ,.g^:(<10) 9
> 
> 9
> 
> 81
> 
> 641
> 
> 36161
> 
> 9361361
> 
> 8193619361
> 
> 641819361819361
> 
> 36161641819361641819361
> 
> 93613613616164181936136161641819361
> 
> 8193619361936136136161641819361936136136161641819361
> 
> 
> I think the difference between R.E.'s/my idea at one side, and Mike's or
> Roger's at the other, is that we actually compute the numbers of the
> sequence, whereas they 'only' generate the strings. Or is that futile?
> 
> 
> Greetings
> 
> Ben
> 
> On Tue, May 14, 2019 at 12:07 AM Roger Hui <[email protected]>
> wrote:
> 
> >    f=: ; @: (*:&.".&.>) @: ":
> >
> >    f 9
> > 81
> >    f f 9
> > 641
> >    f f f 9
> > 36161
> >
> >    f^:(i.10) 9
> > |domain error
> > |       f^:(i.10)9
> >
> > This last runs afoul because of f^:0]9 which has a numeric result and
> > can not be mixed with the other f^:n]9.  It can be fixed by
> > preapplication of
> > ": or by starting with '9', or by not doing f^:0 of course.
> >
> >    f^:(i.10) ": 9
> > 9
> > 81
> > 641
> > 36161
> > 9361361
> > 8193619361
> > 641819361819361
> > 36161641819361641819361
> > 93613613616164181936136161641819361
> > 8193619361936136136161641819361936136136161641819361
> >
> > On Mon, May 13, 2019 at 2:48 AM R.E. Boss <[email protected]>
> wrote:
> >
> > > Was wrong subject. My mailing is getting rusty too.
> > >
> > >
> > > R.E. Boss
> > >
> > >
> > > > -----Oorspronkelijk bericht-----
> > > > Van: Programming <[email protected]>
> > > > Namens R.E. Boss
> > > > Verzonden: maandag 13 mei 2019 11:07
> > > > Aan: [email protected]
> > > > Onderwerp: Re: [Jprogramming] JELM - Extreme Learning Machine in J
> > > >
> > > > It took me more time than expected to produce the sequence of
> > > > numbers
> > in
> > > > J:
> > > >
> > > > (from Seqfan Mailing list - http://list.seqfan.eu/)
> > > > > Beginning with a two-digit square, successively replace each
> > > > > digit with its square, then repeat.
> > > > >
> > > > > For example,
> > > > >                                   9
> > > > >                                  81
> > > > >                                 641
> > > > >                               36161
> > > > >                             9361361
> > > > >                          8193619361
> > > > >                     641819361819361
> > > > >             36161641819361641819361
> > > > > 93613613616164181936136161641819361
> > > >
> > > >    ((]#.~ 10x^10>:@<.@^.]) *:@(10&#.^:_1))^:(i.10)9
> > > > 9 81 641 36161 9361361 8193619361 641819361819361
> > > > 36161641819361641819361 93613613616164181936136161641819361
> > > > 8193619361936136136161641819361936136136161641819361
> > > >
> > > > Curious about other, more elegant solutions, since my J is getting
> > rusty.
> > > >
> > > >
> > > > R.E. Boss
> > > > ------------------------------------------------------------------
> > > > ---- 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