News for hackers. Stuff that matters.
Re:FizzBuzz in J, Explained by acqq on Thursday January 19, 2017 @06:06PM (#13440310)
Thanks! So I made more than one bad guess. So >: can be monadic, increment and dyadic, bigger or equal. And i. can be a generator or an index of.

But how to avoid reading the wrong meaning? If I'm reading right to left, I read 100, then I see i. then see something on the left of i. then why is it not a dyadic i. ? Because there is no parenthesis?

Re:FizzBuzz in J, Explained by klibertp on Thursday January 19, 2017 @06:18PM (#13440370)
> But how to avoid reading the wrong meaning?

The only thing other than "practice" you can do is to use built-in J expression pretty-printer. It shows you a graph of an expression, grouping verbs with their arguments. I don't remember how to get to it exactly, I think it was somewhere in foreigns.

EDIT: it's even mentioned in the article, don't know how I missed it: 5!:4

Re:FizzBuzz in J, Explained by acqq on Thursday January 19, 2017 @06:40PM (#13440492)
Thanks. I've seen it but now that you mentioned I really liked to also understand what that means semantically:

5!:4 <'FB'

I see here:

http://www.jsoftware.com/help/dictionary/dx005.htm

That every combination of two numbers means something special.

http://www.jsoftware.com/help/dictionary/dx018.htm

Wow.

Re:FizzBuzz in J, Explained by Avshalom on Thursday January 19, 2017 @06:14PM (#13440351)
In this case i. is monadic because the thing to the left (>:) is a verb(function). It can get ugly because J has weird precedence/associative rules to let it be tacit but this isn't one of those cases

>: Is monadic because I guess " is special? And has a higher precedence than other things?

Re:FizzBuzz in J, Explained by avmich on Friday January 20, 2017 @12:20AM (#13441870)
" is conjunction, it binds to its arguments - in this case left FB and right 0 - stronger than those bind to their arguments. >: is verb, i. another verb, so

>: i. 100

is understood as

>: (i. (100))

- as two monadic (one-argument) functions applied sequentially.

To the left of that application sits the next verb -

FB"0

which applied next, so the whole thing is

FB"0 (>: (i. (100)))

Precedence/associative rules are: all verbs from right to left, all adverbs/conjunctions from left to right, adverbs/conjunctions are higher by precedence than verbs. That's it.

Re:FizzBuzz in J, Explained by Avshalom on Friday January 20, 2017 @04:44PM (#13447214)
>Precedence/associative ... That's it.

Until you get to hooks and forks.

Re:FizzBuzz in J, Explained by avmich on Saturday January 21, 2017 @02:01AM (#13449204)
Well, we also didn't mention foreigns (like, functions dealing with OS), punctuation, predefined nouns. Hooks and forks also deserve a description, even though I don't think this is about "precedence/associative" matter - both hooks and forks as a whole are verbs, so verbs rules apply.