I don't think

   1 2 3 (+/) 1 2 3

is a good example. Or at least, I am having a problem thinking of
parsing rules that could work under any circumstances where that
parenthesis would be a problem.

A valid example would be:
   +/ .*

If we did not have the current parsing rules, you would need to instead do:
   (+/) .*

because / is not a verb, and with right to left adverb parsing J would
be trying to form this expression:
   +(/ .*)

Does that make sense?

Thanks,

-- 
Raul


On Fri, Mar 3, 2017 at 6:08 AM, bill lam <[email protected]> wrote:
> J always executes _starting_ from right to left,
> but when it encounters adverbs or conjunctions, it
> binds to the left.  Otherwise you need extra
> brackets for them, eg instead of writing
>   1 2 3 +/ 1 2 3
>
> you have to write
>   1 2 3 (+/) 1 2 3
>
> in your example, if it changed to
>   ]^:y 5  which means (]^:y) 5
>
> then it runs ok.
>
> Чт, 02 мар 2017, Linda A Alvord написал(а):
>> Raul,
>>  This works, but I didn't expect that it would:
>> |
>>     fibjb=: 13 :'}:(,[:+/ (_2&{.))^:y 1'
>>
>> If:
>>    y=:5
>>    y 5
>> |syntax error
>> |       y 5
>>
>>    When does J get executed from left to right, and when is it from right to 
>> left?
>>
>> Linda
>>
>> -----Original Message-----
>> From: Programming [mailto:[email protected]] On 
>> Behalf Of Raul Miller
>> Sent: Thursday, March 2, 2017 2:53 PM
>> To: Programming forum
>> Subject: Re: [Jprogramming] Explicit fib
>>
>> These are equivalent:
>>
>>    (,+/ @(_2&{.))^:4(1)
>> 1 1 2 3 5
>>    (,+/ @(_2&{.))(,+/ @(_2&{.))(,+/ @(_2&{.))(,+/ @(_2&{.))(1)
>> 1 1 2 3 5
>>
>> In other words, (F)^:4 does F four times.
>>
>> Does this help?
>>
>> Thanks,
>>
>> --
>> Raul
>>
>> On Thu, Mar 2, 2017 at 2:38 PM, Linda A Alvord <[email protected]> 
>> wrote:
>> > Joe, this has taken me a while because I like to understand something, at 
>> > least a  little bit, before I respond.  I can't quite how this works.
>> >
>> >     (,+/ @(_2&{.))^:14(1)
>> > 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610
>> >
>> > You get an extra term, but I could define your verb.
>> >
>> >    fibjb=: 13 :'}:(,[:+/ (_2&{.))^:y 1'
>> >    fibjb 14
>> > 1 1 2 3 5 8 13 21 34 55 89 144 233 377
>> >
>> > But I wish I could understand how it works as it looks so simple.
>> >
>> > A tree didn't help much:
>> >
>> >
>> >   5!:4 <'fibjb'
>> >       ┌─ 3
>> > ── : ─┴─ ,:'}:(,[:+/ (_2&{.))^:y 1'
>> >
>> > Dissect seemed to withhold its secrets.  SO it's up to you to help me.'
>> >
>> >    load 'debug'
>> >    dissect 'fibjb 14'
>> >
>> > Thanks in advance.  Linda
>> >
>> > -----Original Message-----
>> > From: Programming [mailto:[email protected]] On
>> > Behalf Of Joe Bogner
>> > Sent: Monday, February 27, 2017 9:49 AM
>> > To: [email protected]
>> > Subject: Re: [Jprogramming] Explicit fib
>> >
>> > This is how I would approach it for young children -- attempting to
>> > follow your english description
>> >
>> > fibJ =: 3 : 0
>> >
>> > firstLast =. 1
>> > secondLast =. 0
>> > total =. 1
>> >
>> > for_N. i. (y-1) do.
>> >
>> > term =. (firstLast + secondLast)
>> > secondLast =. firstLast
>> > firstLast =. term
>> >
>> > total =. total,term
>> >
>> > end.
>> > total
>> > )
>> > fibJ 15
>> > 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610
>> >
>> > The definition is simpler if you just want the Nth number
>> >
>> > fibJ =: 3 : 0
>> >
>> > firstLast =. 1
>> > secondLast =. 0
>> >
>> > for_N. i. (y-1) do.
>> >
>> > term =. (firstLast + secondLast)
>> > secondLast =. firstLast
>> > firstLast =. term
>> > end.
>> > term
>> > )
>> > fibJ 15
>> > 610
>> >
>> >
>> >
>> > On Mon, Feb 27, 2017 at 9:16 AM, David Lambert <[email protected]> 
>> > wrote:
>> >>    fib3=: 13 :'}.1|.,''),(fib2 '',"_ 1":i.y,1'
>> >>
>> >>    ". fib3 6
>> >> 0 1 1 2 3 5
>> >>
>> >>
>> >> Let's reorganize by grouping all the strings to increase the sentence
>> >> legibility.
>> >>
>> >>    '),(fib2 ' ,"_ 1  ": ,. i. 7
>> >> ),(fib2 0
>> >> ),(fib2 1
>> >> ),(fib2 2
>> >> ),(fib2 3
>> >> ),(fib2 4
>> >> ),(fib2 5
>> >> ),(fib2 6
>> >>
>> >> From here ravel, rotate by one position, finally discard the extra comma.
>> >>
>> >>
>> >> On 02/27/2017 07:00 AM, [email protected] wrote:
>> >>>
>> >>> Date: Mon, 27 Feb 2017 05:01:34 -0500
>> >>> From: "Linda A Alvord"<[email protected]>
>> >>> To:<[email protected]>
>> >>> Subject: Re: [Jprogramming] Explicit fib
>> >>> Message-ID: <000301d290e0$7ae35ac0$70aa1040$@net>
>> >>> Content-Type: text/plain;       charset="utf-8"
>> >>>
>> >>> I like fib2 and things were going well but I hit a snag:
>> >>>
>> >>> ]W=:*i.2 2
>> >>> 0 1
>> >>> 1 1
>> >>>         mp=:+/ . *
>> >>>         fib2=:3 : '{. W&mp^:y 0 1'
>> >>>     ". }:, (14 5$'(fib2'),"1 (' ',"1  ' ',"1 ":,.>:i.14),"1 '),'
>> >>> 1 1 2 3 5 8 13 21 34 55 89 144 233 377
>> >>>          fib3=: 13 :' ". }:, ((y,5)$'(fib2'),"1 (' ',"1  ' ',"1
>> >>> ":,.>:i.y),"1 '),''
>> >>> |domain error: fib2
>> >>> |   {.W&mp    ^:y 0 1
>> >>>     It doesn't like the fact that that the fib2 should still be just
>> >>> letters.
>> >>>
>> >>> It was fun anyway.   Linda
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> - 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
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>
> --
> regards,
> ====================================================
> GPG key 1024D/4434BAB3 2008-08-24
> gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
> gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
> ----------------------------------------------------------------------
> 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