Thanks - glad to hear it's not a "code smell" per se.
I do like the rewritten form, especially with some names
Example:
validIds (((alpha i. ]) { alpha |.~ [) each '-' cut ]) each validCodes
Broken up:
decrypt =: ((alpha i. ]) { alpha |.~ [) each '-' cut ]
343 decrypt 'mvhkvbdib-kmjezxodgz-mvwwdo-omvdidib'
┌─────────┬──────────┬──────┬────────┐
│rampaging│projectile│rabbit│training│
└─────────┴──────────┴──────┴────────┘
This can then be plugged in nicely to "each" to apply to each record
validIds decrypt each validCodes
┌──────────────────────────────────────┬──────────────────────────────────┐
│┌─────────┬──────────┬──────┬────────┐│┌───────┬─────┬──────┬───────────┐│
││rampaging│projectile│rabbit│training│││onsumer│grade│flower│acquisition││
│└─────────┴──────────┴──────┴────────┘│└───────┴─────┴──────┴───────────┘│
└──────────────────────────────────────┴──────────────────────────────────┘
On Mon, Jan 9, 2017 at 9:14 AM, Raul Miller <[email protected]> wrote:
> Well...
>
> it's certainly appropriate, given the data structure you are working with.
>
> That said, you could rephrase it to eliminate that artifact:
>
> validIds ([ ((alpha i. ]) { alpha |.~ [) each '-' cut ]) each validCodes
>
> This saves construction of two boxes at the expense of slightly more
> parsing.
>
> Thanks,
>
> --
> Raul
>
>
> On Mon, Jan 9, 2017 at 8:47 AM, Joe Bogner <[email protected]> wrote:
> > I'm back to working on Advent of Code. I'm on day 4, a bit late I know.
> >
> > I have "each each" in my solution which doesn't feel right to me.
> >
> > Here's a reproducible case:
> >
> > validCodes =:
> > ('mvhkvbdib-kmjezxodgz-mvwwdo-omvdidib';'zydfxpc-rclop-
> qwzhpc-lnbftdtetzy')
> > validIds=: 837 171
> > alpha =: 'abcdefghijklmnopqrstuvwxyz'
> >
> > validIds ((alpha i. ]) { alpha |.~ [) each each '-' cut each validCodes
> >
> >
> > ┌──────────────────────────────────────┬────────────────────
> ──────────────┐
> > │┌─────────┬──────────┬──────┬────────┐│┌───────┬─────┬─────
> ─┬───────────┐│
> > ││rampaging│projectile│rabbit│training│││onsumer│grade│
> flower│acquisition││
> > │└─────────┴──────────┴──────┴────────┘│└───────┴─────┴─────
> ─┴───────────┘│
> > └──────────────────────────────────────┴────────────────────
> ──────────────┘
> >
> > Does the "each each" feel out of place? If so, how would it be
> eliminated?
> > ----------------------------------------------------------------------
> > 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