4 ms·
Author here. Sorry to hear that. If you want to let me know where I lost you via email or here, I'd be happy to revise it to be clearer. I think it takes a cer
by wyc 10y ago
Author here. Sorry to hear that. If you want to let me know where I lost you via email or here, I'd be happy to revise it to be clearer.
I think it takes a certain skill to overcome the curse of already knowing something and then explaining it, and I'll definitely have some blind spots.
Thanks for reading it twice!
- acqq 10y agoConsider that on HN there are surely people who read about J the first time, or if they have read something somewhere, they already forgot it and they won't go through the whole tutorial (which is not small) before reading the article. For example, I guess that the FB"0 >:i.100 is a kind-of for loop, even if I also guess it's not called as such in J, but I wouldn't be able to explain how it exactly works, except that >: is bigger or equal, which I glimpsed from some first page of the tutorial, and i. should mean index of, according to your text? But searching 100 in what? Or is it some new word? Then, why was 1337 introduced in the explanation at all? I failed to understand, reading the text not too slowly. Thanks for posting the article here, it's refreshing.
- Avshalom 10y agoFB"0 basically means apply FB to each cell in an array. i.100 makes an array of numbers 0...99 and >: increments every number in that array by 1 So it's mapping FB over the numbers 1 to 100. Now I don't know j very well so I don't know why this evaluates as (FB"0) (>:i.100) instead of (FB") (0>:i.100) but I guess " is special 1337 is just a stand in number. To try the algorithm without mapping it to an array. So the algorithm is this make an array of [fizzbuzz fizz buzz x]. Then make an array of x mod 15, 3, 5. Find the first instance of 0 in that second array and use that index to select fizz,buzz etc. If there isn't a zero (0 i. secondarray) returns the length of secondarray which is 3, the same index as x in the first array.
- acqq 10y agoThanks! 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?
- Avshalom 10y agoIn 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?
- avmich 10y ago" 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.
- Avshalom 10y ago>Precedence/associative ... That's it. Until you get to hooks and forks.
- avmich 10y agoWell, 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.
- B1FF_PSUVM 10y agoJ makes my brain hurt, but in a much saner way than thisCamelCasedVariableNameIsNotNearlyLongEnoughToBeSufficientlyClear...WhereWasIGoing? So, props.