I have been experimenting with code to implement the parsing of Jimmy's
idea and example.
However, I am stuck on an application of agenda and would like some help.
ni =: [:(<./,]i.<./)(;:'S SE SW') i.~ ]
n0 =: a:-.~(a:"_)`(0,{.@[)`]}
n1 =: a:-.~(('NE';a:)"_)`(0,{.@[)`]}
n2 =: a:-.~(('NW';a:)"_)`(0,{.@[)`]}
na =: n0`n1`n2@.{:@[ NB. not used in the explicit verb that works!
ex1 =: 'SE NE N NW NW NE NE S SW SW'
The following verb named choose does what I want, but I would like to use
agenda instead because agenda seems more tacit. I have only tested choose
and
my intended, but faulty, code with Jimmy's case 0 = N + S, but I hope to
generalize and expand it.
choose =: monad define
ch =. ni y
select. {: ch
case. 0 do. return =. ({.ch)n0 y
case. 1 do. return =. ({.ch)n1 y
case. 2 do. return =. ({.ch)n2 y
end.
)
choose 2}.;:ex1 NB. the desired result!
┌──┬──┬──┬──┬──┬──┐
│NW│NW│NE│NE│SW│SW│
└──┴──┴──┴──┴──┴──┘
NB. I'm trying to operate on the 0=N+S
NB. example
ni 2}.;:ex1
5 0
5 0 n0 2}.;:ex1 NB. This produces my expected result
┌──┬──┬──┬──┬──┬──┐
│NW│NW│NE│NE│SW│SW│
└──┴──┴──┴──┴──┴──┘
(ni na ]) 2}.;:ex1
|rank error: n0
| (ni na])2}.;:ex1
My problem is not being able to use the agenda verb na
to produce the gerund forms in amend verbs n0, n1 and n2.
On Wed, Dec 13, 2017 at 4:22 PM, Jimmy Gauvin <[email protected]>
wrote:
> HI,
>
> I have been thinking about Brian's "cancellation" approach and maybe we can
> sort of formalize it.
>
> Associative relations for cancelling paths:
>
> 0 = N + S = S + N
> 0 = NE + SW = SW + NE
> 0 = NW + SE = SE + NW
>
> Associative relations for simplifying paths:
>
> N = NE + NW = NW + NE
> S = SE + SW = SE + SW
> NE = N + SE = SE + N
> NW = N + SW = SW + N
> SE = S + NE = NE + S
> SW = S + NW = NW + S
>
> Please note that destinations are equivalent but the paths are different.
>
> Now we can do symbolic algebraic simplification.
>
> For example :
>
> ┌──┬──┬─┬──┬──┬──┬──┬─┬──┬──┐
> │SE│NE│N│NW│NW│NE│NE│S│SW│SW│
> └──┴──┴─┴──┴──┴──┴──┴─┴──┴──┘
>
> N = NW + NE and SE = NE + S
> ┌──┬──┬─┬──┬──┬──┬──┬─┬──┬──┐
> │SE│NE│N│NW│N │ │SE│ │SW│SW│
> └──┴──┴─┴──┴──┴──┴──┴─┴──┴──┘
>
> S = SE + SW
> ┌──┬──┬─┬──┬──┬──┬──┬─┬──┬──┐
> │SE│NE│N│NW│N │ │S │ │ │SW│
> └──┴──┴─┴──┴──┴──┴──┴─┴──┴──┘
>
> 0 = N + S
> ┌──┬──┬─┬──┬──┬──┬──┬─┬──┬──┐
> │SE│NE│N│NW│ │ │ │ │ │SW│
> └──┴──┴─┴──┴──┴──┴──┴─┴──┴──┘
>
> 0 = SE + NW
> ┌──┬──┬─┬──┬──┬──┬──┬─┬──┬──┐
> │ │NE│N│ │ │ │ │ │ │SW│
> └──┴──┴─┴──┴──┴──┴──┴─┴──┴──┘
>
> 0 = NE + SW
> ┌──┬──┬─┬──┬──┬──┬──┬─┬──┬──┐
> │ │ │N│ │ │ │ │ │ │ │
> └──┴──┴─┴──┴──┴──┴──┴─┴──┴──┘
>
> The count of remaining symbols is the distance in number of steps.
>
> Programming this is left as an exercise to the reader.
>
>
> On Tue, Dec 12, 2017 at 3:08 PM, Brian Schott <[email protected]>
> wrote:
>
> > No. That's not right. I need to repair my approach.
> >
> > On Tue, Dec 12, 2017 at 2:04 PM, Brian Schott <[email protected]>
> > wrote:
> >
> > > Another way to approach this problem first part, which was refined by
> > > Jimmy's
> > > elegant solution, follows.
> > >
> > >
> > >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
(B=) <-----my sig
Brian Schott
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm