[Jprogramming] Am I understanding m/y ?
Linda A Alvord
lindaalvord at verizon.net
Tue Feb 23 04:39:32 UTC 2016
Not a bug...
Raul's example: First insert symbols from left to right.
+`*/3 4 5
23
(and J executes from right to left.) ( "reverse Polish") (Hopefully the correct term is)
Linda
-----Original Message-----
From: Programming [mailto:programming-bounces at forums.jsoftware.com] On Behalf Of Michal Wallace
Sent: Monday, February 22, 2016 5:24 PM
To: programming at jsoftware.com
Subject: Re: [Jprogramming] Am I understanding m/y ?
The example in the docs is ambiguous, and probably ought to be replaced, since the sequence of inserted verbs both starts and ends with +.
I'm not sure that I'd find either order to be more or less useful, but the existing order does have one nice advantage, in that it allows you to "factor out" verbs in an otherwise constant expression, and keep them in the original order:
3 * 2 + 1 -> *`+/3 2 1
On Mon, Feb 22, 2016 at 4:16 PM, Raul Miller <rauldmiller at gmail.com> wrote:
> Note also that if (3*4+5) -: +`*/3 4 5 this gerund mechanism would be
> useful for implementing a solution to your minimization problem, using
> something like
> C#inv!._1 (#~ 0 1$~#)|.+`<./\.|. (C=:D~:_1)#D,.P
>
> That's untested code, for obvious reasons, but I think it would be in
> the right ballpark.
>
> So my question is: is the existing implementation useful for anything?
>
> Thanks,
>
> --
> Raul
>
>
>
>
> On Mon, Feb 22, 2016 at 5:07 PM, Raul Miller <rauldmiller at gmail.com>
> wrote:
> > Spelled out in nuvoc doesn't mean it's not an error:
> >
> > It's quite possible to document erroneous behavior.
> >
> > --
> > Raul
> >
> > On Mon, Feb 22, 2016 at 4:52 PM, Henry Rich <henryhrich at gmail.com>
> wrote:
> >> Inserts from the front.
> >>
> >> +`*/3 4 5
> >>
> >> 23
> >>
> >> 3+4*5
> >>
> >> 23
> >>
> >>
> >> Spelled out in
> >>
> >> http://code.jsoftware.com/wiki/Vocabulary/slash#Details
> >>
> >> Henry Rich
> >>
> >> On 2/22/2016 4:21 PM, Raul Miller wrote:
> >>>
> >>> http://www.jsoftware.com/help/dictionary/d420.htm says:
> >>>
> >>> m/y inserts successive verbs from the gerund m between items of y,
> >>> extending m cyclically as required. Thus, +`*/i.6 is 0+1*2+3*4+5
> >>>
> >>> But it does not include an example of m/y where y contains an odd
> >>> number of elements.
> >>>
> >>> From the description, I would expect +`*/3 4 5 to give the result
> 3*4+5
> >>>
> >>> However:
> >>> 3*4+5
> >>> 27
> >>> +`*/3 4 5
> >>> 23
> >>>
> >>> I'm thinking that this might be a bug in the interpreter.
> >>>
> >>> Is there some application, though, that requires the current behavior?
> >>>
> >>> Thanks,
> >>>
> >>
> >> -------------------------------------------------------------------
> >> --- 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
More information about the Programming
mailing list