Yeah, but I was just waking up and did not read Cliff's message
carefully enough.

Here's what I think he was after:

c1=: {{+/1=10#.^:_1]y}}"0
F=: {{{.N#~y=+/\c1 N=.>:i.10>.5*y}}

   F 213
521

This uses his proposed components, achieves what he asked for, and
eliminates the 'n' which would make F be an adverb.

That said, I think c1 should be defined without "0 (for efficiency):

   c1=: {{+/"1]1=10#.^:_1]y}}

This way, c1 only needs to be evaluated once on a list, rather than
being evaluated once for each member of the list. And, because c1's
definition mostly uses dyadic verbs, c1 lends itself easily to a tacit
(mostly forks) representation:

   c1=: 1 +/"1@:= 10 #. ^:_1 ]

Thanks,

--
Raul


On Sun, Jan 23, 2022 at 3:44 AM Hauke Rehr <hauke.r...@uni-jena.de> wrote:
>
> ones1 reads better than the original.
> factoring out {. and }. really helps.
> even though it means pairs of factors
> are “distributed” and one doesn’t
> immediately see which one is corresponding.
> if it hadn’t been for having it fit on one line,
> I had kept the recursive call separate, though.
>
> Am 23.01.22 um 09:06 schrieb Raul Miller:
> > If you are working with a limited range, you can use I. to conduct the 
> > search.
> >
> > For example,
> >
> > ones1=: (1,1&<,1&=,])@{. +/@:* (0:`$:@.(0<#),(10^#),(1+10#.]),#*10^#-1:)@}.
> > ones=: 10 ones1@:(#.inv)"0 ]
> >
> > senO=: ] I.~ [: +/\1+/"1@:=10 #.inv [: i. +:@]^:(> ones)^:_~
> >
> > Here, I used a golfed version of Hauke Rehr's 'ones' verb in an
> > estimator for a bound on the list length that I needed to search (I
> > shortened it to avoid email line wrap issues). But we could use
> > something else to perform the estimate.
> >
> > The limitation here is that we have to form an intermediate result
> > large enough to search. So you start getting noticeable lag around 3e5
> > and you probably don't want to go much beyond 1e6 very often.
> >
> > I hope this helps,
> >
>
> --
> ----------------------
> mail written using NEO
> neo-layout.org
>
> ----------------------------------------------------------------------
> 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