Actually, looking at this, I am already seeing a simplification I
could have made:
use=: {{
depth=. +/\-/'[]'=/y
sel=. _1|.0 1 E.{~mask=.-.y e. '[,]'
vals=.".mask #inv mask#y
assert. (+/sel)=#vals
(sel#depth),:vals
}}
--
Raul
On Wed, Dec 22, 2021 at 4:27 PM Raul Miller <[email protected]> wrote:
>
> My plan is to post about aoc18 in another 16 days (I am planning on
> spacing these posts out, one per day -- basically lagging the original
> puzzles each by 20 days).
>
> That said, I didn't use much boxing for aoc18. Maybe if I show the
> line parsing routine, that I used, it will give you a hint?
>
> use=: {{
> depth=. +/\-/'[]'=/y
> sel=. _1|.' .'E.' .'{~mask=.-.y e. '[,]'
> vals=.".mask #inv mask#y
> assert. (+/sel)=#vals
> (sel#depth),:vals
> }}
>
> I hope this helps,
>
> --
> Raul
>
>
>
>
> I hope this helps,
>
>
> --
> Raul
>
> On Wed, Dec 22, 2021 at 3:59 PM 'Michael Day' via Programming
> <[email protected]> wrote:
> >
> > Apologies - more chat than programming, but: fwiw, for part 1, I just
> > defined simple
> > one-liner functions "forward" etc which worked ok. For part 2, they
> > needed redefining, and,
> > yes, I used direct defs; nothing as sophisticated as fold!
> >
> > I've done days 1-17, mostly straightforward, some very fiddly.
> >
> > But I'm stuck at 18, which is v complicated in its explanation. I
> > started with boxes in J,
> > but found navigation hard - I haven't used nested structures much in J -
> > so resorted to
> > working on the untranslated rows, using ;: to separate the symbols &
> > numbers, but
> > couldn't get all the examples to reproduce the stated results! So
> > I've wasted yet more time
> > learning - or relearning - how to deal with nested arrays in Dyalog APL
> > and remembering how
> > to use John Scholes' dfns. Managed to "reduce" the "addition" of the
> > first pair of snailnumbers,
> > but reducing the "addition" of the third line defeats me. I suppose I'm
> > sometimes inserting
> > some result at the wrong depth.
> >
> > I've spent so much time on that that I'll probably give up the rest!
> >
> > Cheers,
> >
> > Mike
> >
> >
> > On 22/12/2021 14:59, Raul Miller wrote:
> > > (responding to
> > > http://jsoftware.com/pipermail/programming/2021-December/059436.html#)
> > >
> > > I am not sure that I thought this example out well enough for it to be
> > > good on an examples page.
> > >
> > > For instance, after thinking about it for just a few minutes, I realized
> > > that
> > >
> > > b2fold=: 0 0 0&(}.F..{{
> > > 'dH0 dA0 N'=. x
> > > 'A H D'=. y
> > > dA=: N*dA0
> > > dH=: N*dH0
> > > dD=: A*dH
> > > y+dA,dH,dD
> > > }})
> > >
> > > b2=: {{*/b2fold y}}
> > >
> > > would have been clearer.
> > >
> > > (Originally I was using ]F.. and commenting that I needed to drop the
> > > first item of the result. But isn't it clearer to include that drop
> > > mechanism with the fold implementation?)
> > >
> > > But (and this is worse): this particular example lacks utility, which
> > > means that it's not going to be very interesting for anyone.
> > >
> > > Other opportunities will arise, though. And I think that your concept
> > > of linked example pages is a good one and worth following up on.
> > >
> > > Thanks,
> > >
> >
> >
> > --
> > This email has been checked for viruses by Avast antivirus software.
> > https://www.avast.com/antivirus
> >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm