Re: [Jprogramming] Sierpinski triangle

2022-02-02 Thread Andrew P
Xash: (3 ({. ~: {:)\ 0,],0:) That's brilliant! It only took me 5 minutes to understand what this means this time :-) Elijah: Thank you for the clarification. The adverb rule is foreign to me, I will have to explore some examples to see why it makes sense for it to be different from the verb rule.

Re: [Jprogramming] Sierpinski triangle

2022-02-02 Thread xash
> Now why steps 10-13 result in the next row of a sierpinski triangle, I > don't know, I guess it has to do with generating a Pascal triangle. It's not that important for learning J, but it gives a hint why the seemingly confusing `72#:~8#2` was used. `bm{~3#.\row` maps three consecutive bits to

Re: [Jprogramming] Sierpinski triangle

2022-02-01 Thread chris burke
I know this question is about understanding some J code, but perhaps it is worth noting that the Jqt Studio|Showcase|isigraph demo has other examples, including Cliff Reiter's elegant: load 'viewmat' viewmat (,,.~)^:8 ,1 --

Re: [Jprogramming] Sierpinski triangle

2022-02-01 Thread Elijah Stone
On Wed, 2 Feb 2022, Andrew P wrote: A question that I have is: can V0 V1 V2 V3 V4 can become V0 V1 V2 (V3 V4) instead of V0 V1 (V2 V3 V4)? Nope. A way to think about it is that the parser eats verbs from the right, as many as it can handle. So if you start with V0 V1 V2 V3 V4 V5, it first

Re: [Jprogramming] Sierpinski triangle

2022-02-01 Thread Andrew P
Hello everyone, First of all, thank you so much for all the responses. After reading each one multiple times and spending several hours looking at this program, I think that I have made progress. Hauke: I hadn't noticed that parentheses were, as a rule of thumb, matched. About dissect: it is not

Re: [Jprogramming] Sierpinski triangle

2022-02-01 Thread Raul Miller
It's probably worth noting here that the {: here is used to grab the last row of the partial result which is being built. Initially, this is a list of y zeros, followed by a 1, followed by y zeros. ,: 1 (15)} (>:+:15) $ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Note

Re: [Jprogramming] Sierpinski triangle

2022-02-01 Thread Brian Schott
Andrew, your observations are correct. Now consider this part which is an amend to create and amend a long list of zeroes. 1 (15)} (>:+:15) $ 0NB. beware, of long result 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 $,:1 (15)} (>:+:15) $ 0 NB. ,: forces a new dimension

Re: [Jprogramming] Sierpinski triangle

2022-02-01 Thread Hauke Rehr
another approach that could be helpful with respect to that question: try removing that , and rearranging )@{:)^:y to become )^:y)@{: in the definition what does it compute now? Sierpinski =: {{ (((72#:~8#2){~3#.\0,],0:)^:y)@{: ,: 1 y} (>:+:y) $ 0 }} ' #'{~ Sierpinski"0 i.>:15 This gives

Re: [Jprogramming] Sierpinski triangle

2022-02-01 Thread R.E. Boss
20:10 To: programm...@jsoftware.com Subject: Re: [Jprogramming] Sierpinski triangle Hello, Besides dissect that I really like, Art's flowtree ( https://code.jsoftware.com/wiki/User:Art_Anger/FlowTree) looks pretty interesting too, but I haven't used it much yet. Best regards, On Tue, Feb 1, 2022 a

Re: [Jprogramming] Sierpinski triangle

2022-02-01 Thread Michail L. Liarmakopoulos
Hello, Besides dissect that I really like, Art's flowtree ( https://code.jsoftware.com/wiki/User:Art_Anger/FlowTree) looks pretty interesting too, but I haven't used it much yet. Best regards, On Tue, Feb 1, 2022 at 7:59 PM Hauke Rehr wrote: > You already understood that some kinds of

Re: [Jprogramming] Sierpinski triangle

2022-02-01 Thread Hauke Rehr
You already understood that some kinds of brackets don’t come in balanced pairs. But parentheses () nearly always do, the exceptions being inside of strings, obviously, and closing ) on a line of its own (which doesn’t occur here, so I won’t explain that). (oh, and {{…}} introduced another

[Jprogramming] Sierpinski triangle

2022-02-01 Thread Andrew P
I have found in a forum the following J code that generates a Sierpinski triangle, and am trying to understand how it works. sierpinski =: {{ (, ((72#:~8#2){~3#.\0,],0:)@{:)^:y ,: 1 y} (>:+:y) $ 0 }} ' #'{~ sierpinski 15 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #