On Wed, Dec 2, 2015 at 10:32 AM, Geoff Canyon <[email protected]> wrote: > Is that because @ binds more tightly than / or am I thinking in C terms?
See: http://www.jsoftware.com/help/dictionary/dicte.htm Also: require 'trace' trace '(+: @ +/ @: =&'')'' )' --------------- 4 Conj ------- +: @ + +:@+ --------------- 3 Adverb ----- +:@+ / +:@+/ --------------- 4 Conj ------- +:@+/ @: = +:@+/@:= --------------- 4 Conj ------- +:@+/@:= & ')' +:@+/@:=&')' --------------- 8 Paren ------ ( +:@+/@:=&')' ) +:@+/@:=&')' ============================== Here's how J would parse it ('EDGE';'VERB';'CONJ';'VERB';'ADV';'CONJ';'VERB';'CONJ';'NOUN';'') ,. (;:'(+: @ +/ @: =&'')'' )') (right par is nothing) ┌────┬───┐ │EDGE│( │ ├────┼───┤ │VERB│+: │ ├────┼───┤ │CONJ│@ │ ├────┼───┤ │VERB│+ │ ├────┼───┤ │ADV │/ │ ├────┼───┤ │CONJ│@: │ ├────┼───┤ │VERB│= │ ├────┼───┤ │CONJ│& │ ├────┼───┤ │NOUN│')'│ ├────┼───┤ │ │) │ └────┴───┘ Given this set of rules: EDGE VERB NOUN ANY 0 Monad EDGE+AVN VERB VERB NOUN 1 Monad EDGE+AVN NOUN VERB NOUN 2 Dyad EDGE+AVN VERB+NOUN ADV ANY 3 Adverb EDGE+AVN VERB+NOUN CONJ VERB+NOUN 4 Conj EDGE+AVN VERB+NOUN VERB VERB 5 Fork EDGE CAVN CAVN ANY 6 Bident NAME+NOUN ASGN CAVN ANY 7 Is LPAR CAVN RPAR ANY 8 Paren The parser works right to left ;"1 |.\ |. ;:'(+: @ +/ @: =&'')'' )' ) ')') &')') =&')') @:=&')') /@:=&')') +/@:=&')') @+/@:=&')') +:@+/@:=&')') (+:@+/@:=&')') or |.\ |. ('EDGE';'VERB';'CONJ';'VERB';'ADV';'CONJ';'VERB';'CONJ';'NOUN';'') ┌────┬────┬────┬────┬────┬────┬────┬────┬────┬┐ │ │ │ │ │ │ │ │ │ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │NOUN│ │ │ │ │ │ │ │ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │CONJ│NOUN│ │ │ │ │ │ │ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │VERB│CONJ│NOUN│ │ │ │ │ │ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │CONJ│VERB│CONJ│NOUN│ │ │ │ │ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │ADV │CONJ│VERB│CONJ│NOUN│ │ │ │ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │VERB│ADV │CONJ│VERB│CONJ│NOUN│ │ │ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │CONJ│VERB│ADV │CONJ│VERB│CONJ│NOUN│ │ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │VERB│CONJ│VERB│ADV │CONJ│VERB│CONJ│NOUN│ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │EDGE│VERB│CONJ│VERB│ADV │CONJ│VERB│CONJ│NOUN││ └────┴────┴────┴────┴────┴────┴────┴────┴────┴┘ The first row that matches is (+:@+ EDGE│VERB│CONJ│VERB│ADV │CONJ│VERB│CONJ│NOUN to EDGE+AVN VERB+NOUN CONJ VERB+NOUN 4 Conj Which is why trace reports this: --------------- 4 Conj ------- +: @ + +:@+ If it was parenthesized it would hit the adverb rule first: trace '(+: @ (+/) @: =&'')'' )' --------------- 3 Adverb ----- + / +/ ('EDGE';'VERB';'CONJ';'EDGE';'VERB';'ADV';'CONJ';'VERB';'CONJ';'NOUN';'') ,. (;:'(+: @ (+/ @: =&'')'' )') ┌────┬───┐ │EDGE│( │ ├────┼───┤ │VERB│+: │ ├────┼───┤ │CONJ│@ │ ├────┼───┤ │EDGE│( │ ├────┼───┤ │VERB│+ │ ├────┼───┤ │ADV │/ │ ├────┼───┤ │CONJ│@: │ ├────┼───┤ │VERB│= │ ├────┼───┤ │CONJ│& │ ├────┼───┤ │NOUN│')'│ ├────┼───┤ │ │) │ └────┴───┘ |.\ |. ('EDGE';'VERB';'CONJ';'EDGE';'VERB';'ADV';'CONJ';'VERB';'CONJ';'NOUN';'') ┌────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬┐ │ │ │ │ │ │ │ │ │ │ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │NOUN│ │ │ │ │ │ │ │ │ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │CONJ│NOUN│ │ │ │ │ │ │ │ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │VERB│CONJ│NOUN│ │ │ │ │ │ │ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │CONJ│VERB│CONJ│NOUN│ │ │ │ │ │ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │ADV │CONJ│VERB│CONJ│NOUN│ │ │ │ │ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │VERB│ADV │CONJ│VERB│CONJ│NOUN│ │ │ │ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │EDGE│VERB│ADV │CONJ│VERB│CONJ│NOUN│ │ │ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │CONJ│EDGE│VERB│ADV │CONJ│VERB│CONJ│NOUN│ │ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │VERB│CONJ│EDGE│VERB│ADV │CONJ│VERB│CONJ│NOUN│ ││ ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼┤ │EDGE│VERB│CONJ│EDGE│VERB│ADV │CONJ│VERB│CONJ│NOUN││ └────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴┘ Which would be this: │EDGE│VERB│ADV │CONJ│VERB│CONJ│NOUN│ │ │ ││ to EDGE+AVNVERB+NOUNADVANY3 Adverb On Wed, Dec 2, 2015 at 10:42 AM, Raul Miller <[email protected]> wrote: > > @ and / both bind more weakly on their left side than on their right > > It's actually slightly different though, because @ also binds tightly > on it's right side. (And, there's a subtle exception in that, which > almost never gets used - if you omit its right side, its left side > binding becomes far weaker (and the result will want to bind on *its* > left side, to get something to bind to the right side of the @).) > > Try this: > 9!:3]5 NB. use linear display form for verb/adverb/.. results > meanie=: +/ % # @ > ] meanie > > Does any of this help? > > Thanks, > > -- > Raul > > On Wed, Dec 2, 2015 at 10:32 AM, Geoff Canyon <[email protected]> wrote: > > On Wed, Dec 2, 2015 at 10:15 AM, Joe Bogner <[email protected]> wrote: > > > >> Without it, J sees (+:@+) / > >> > > > > Is that because @ binds more tightly than / or am I thinking in C terms? > > > > As an aside, I love how J makes me think *completely* differently about > > programming. I have developer friends who think they're multi-lingual > > because they code in PHP and Javascript, and I just smile at them and > > explain +/%# > > ---------------------------------------------------------------------- > > 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
