Yes. In this table (from the Parsing and Execution appendix)
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 @ is processed using rule 4 (Conj), rule 6 (Bident), rule 7 (Is) or rule 8 (Paren). Note that new tokens are injected into the above patterns from the right hand side. So, anyways, if you have a conjunction in the active part of your token stream, the other rules (Monad, Dyad, Fork, Adv) cannot do anything until the conjunction is processed (or moved out of sight, but I think that that always results in a syntax error). -- Raul On Wed, Mar 21, 2012 at 4:39 PM, Alexander Epifanov <[email protected]> wrote: > I did not use [: before, very interesting. > > Do I understand correct and @ has "priority" during parsing? that is > why (-.@2)&| and not (-.)@(2&|), as I expected. > > On Wed, Mar 21, 2012 at 1:20 PM, Ric Sherlock <[email protected]> wrote: >> Comments inline: >> >> On Wed, Mar 21, 2012 at 9:32 PM, Alexander Epifanov <[email protected]> >> wrote: >>> Hello, >>> >>> Could you please explain the followin thing: >>> [ns=:?10#1500 >>> 1225 1362 1263 1376 1445 383 1260 397 175 1188 >>> NB. I try to find 3digit numbers with unique digits. >>> I wrote this: >>> ns#~((((3&=@#) *. (*./@~:))@":)"0) ns >>> I think here are too many brackets, so I removed some >>> ns#~(((3&=@#*.*./@~:)@":)"0) ns >>> >>> Q1: how J understand how to split (xyz) here? How can I parse it in mind? >> >> You can simplify this further. I would use white space to help me >> parse the sentence more easily (the interpreter doesn't care though) >> ns #~ (((3 = #) *. *./@~:)@":)"0 ns >> >> The following article on the wiki may help with understanding how to >> read tacit sentences. >> http://www.jsoftware.com/jwiki/Guides/Reading%20Tacit%20Verbs >> >>> Q2: Why I should write 3&=, but not *.&/ ? >> >> With 3&= you are binding a noun to a verb to create a new verb. With >> *./ the / is an adverb that automatically "binds"/modifies the verb to >> its left. >> >>> After that I did: >>> (((3=#*.*./@~:)@":)"0) ns >>> >>> Q3: It absolutely not clear for me, how can I write 3=# (explicit) >>> instead of 3&=@# (tacit)? >> >> (((3 = #) *. *./@~:)@":)"0 ns >> Note that 3&=@# isn't really tacit in the sense that you aren't using >> forks or hooks. However you haven't referred to the arguments because >> you were able to create the new verb by combining the noun and verbs >> using conjunctions, so in that sense it is tacit. >> >>> It is the main problem in J for me, for example I write expression: >>> [ns2=:i.10 >>> 0 1 2 3 4 5 6 7 8 9 >>> ns2#~-.2|ns2 NB. it looks good, no problem. >>> >>> But the problem, if I would like convert it into the function, I >>> should absolutely rewrite it: >>> >>> ns2#~(-.@(2&|))ns2 NB. additional Q: why 2&| in brakets? >> >> You can write this as a tacit function in a number of ways: >> (] #~ [: -. 2 | ]) ns2 NB. only forks >> (#~ [: -. 2 | ]) ns2 NB. uses hook at end >> (#~ [: -. 2&|) ns2 >> (#~ 2 -.@| ]) ns2 >> (#~ -.@(2&|)) ns2 >> >> You need the 2&| in brackets otherwise it is evaluated (-.@2)&| >> >> Any of these functions can be assigned to a name >> getEven=: (#~ 2 -.@| ]) >> getEven=: #~ 2 -.@| ] NB. the brackets aren't necessary for assignment >> >> >>> @, which is not used in normal expression, that is strange for me that >>> expression and function is not the same, K looks more habitually at >>> this point: >>> expression: ns2:!10; ns2@~ns2!2 >>> function: ns2@{~x!2} ns2 / exactly the same like expression. >>> >>> What is why it is not clear for me why J expression in explicit style >>> by default, but function in tacit. >>> >>> Thank you and sorry if described problem is not very clear. >>> -- >>> Regards, >>> Alexander. >>> ---------------------------------------------------------------------- >>> 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, > Alexander. > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
