@nathanrogers yeah the whole "everything" part isn't "everything" at all, but just functions.
space separated nilads join together first, then operators join in and then functions connect everything together.
@dzaima *"everything" from the phrase "everything gets evaluated right to left"; didn't realize that wasn't specifically said before anywhere
(okay maybe it's kind of true as in a b c d e f g ..., with the letters being any expression, i.e. parentheses, built-ins, function names or literally anything else you put in APL expressions, get executed right to left to figure out what they even are and what to even do with them, but that's just complicated.)
i.e. (⍎'⍞←1⋄1')(⍎'⍞←2⋄2')(⍎'⍞←3⋄+')(⍎'⍞←4⋄+')(⍎'⍞←5⋄/')(⍎'⍞←6⋄3')(⍎'⍞←7⋄4')(⍎'⍞←8⋄5') prints 87654321, and then the result of 1 2++/3 4 5, which are the individual results of each parentheses.
\o/ finished my double-ended priority queue and now the grapher can add ~500k points per second, though with 400k drawn it's at 5fps.. Has exactly 0 practical use, but was good practice for algorithmic efficiency.
@dzaima Almost always. Array. binds stronger than Array Array, so ns1 ns2.x means ns1 (ns2.x) and not (ns1 ns2).x as indicated by the table of binding strengths
@dzaima Hm, interesting issue though. In my proposal (⍞←1 ⋄ ⍞←2) would print 12 to stdout while (⍞←1)(⍞←2) prints 21.
@dzaima Btw, your output format seems a bit odd to me. rank≥3 prints as a dfn with JSON or something? And that isn't valid code? Also, empty arrays are printed as expressions using '' for character arrays but using ? for numeric ones. 0⍴0 gives ? but 0⍴⍬ gives ⍬.
@Adám I found a ½JSON-ish format easier to use than outptting layers separated by spaces of powers of 2 or whatever.. The ? thing just indicates that I haven't defined a prototype for that yet (⍬ does give ⍬)
and I haven't dealt with prototypes pretty much anywhere.
@dzaima I didn't suggest anything. I said to allow brackets only in traditional places. However, one could have / be a dyadic operator: (+/3)array instead of +/[3]array etc.
@dzaima ngn/apl knows in advance what is what in the ast (array / function / monadic operator / dyadic operator), so it doesn't need to evaluate strands right-to-left like dyalog
@nathanrogers The first is just like 10 20 + 5 - except instead of the scalar 5 the right argument of + is the scalar 1 2 3, and so + gets done as (10+1 2 3)(20+1 2 3), just as it does with (10+5)(20+5)
the second example is just a more advanced version of that - just like 1 2+10 20 is (1+10)(2+20), 10 (20 30 40) + (1 2 3)(4 5 6) is (10+(1 2 3)) ((20 30 40)+(4 5 6))
i guess I don't understand why its enclosing anything. 1 ⍵ isn't enclosed and 3 4 isn't enclosed, but then in the expression 1 ⍵∧3 4 ... it IS enclosed. why?
A cell is alive in the next generation if it was (1) dead with three alive neighbours, (2) alive with two alive neighbours, (3) alive with three alive neighbours. This can be simplified slightly to "a cell is alive in the next generation if it had three alive neighbours (including itself), or it had four alive neighbours (including itself) and was alive". This is (3=S)∨⍵∧4=S, where S is a matrix of neighbour counts. This then re-written as (1∧3=S)∨⍵∧4=S then 1 ⍵∨.∧3 4=S.
I was looking for a simple answer to why ⍵∧4=... was returning some crazy unexpected result, but the answer is that ⍵ needs to be boxed for it to return a result like in the expression
@nathanrogers You are using ∧ (a scalar function) on something of shape 10 10 and on something of shape ⍬. In this case the array of shape ⍬ is (scalar) extended to an array of shape 10 10 (where all the elements are identical). then each element of ⍵ (a single number) is ∧'d with each element of the scalar extended right argument (each an enclosed matrix)
It's important to note that the depth and shape are different. The shape is what you expect 10 10. It's just that the elements of the left and right argument are paired up in a different way than you were expecting
It is important to have a very good understanding of how scalar functions work. How the arguments are paired up. The explanation for the result of 1 2 3+⊂4 5 6 is identical to an explanation for the result of {⍵∧4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵}¯3⌽¯3⊖10 10↑5 5↑3 3⍴0 0 1,1 0 1,0 1 1
The result of 1 2+⊂3 4 5 is (1+3 4 5)(2+3 4 5). See how the element count gets multiplied - 2 × 3 = 6 items in the result. We can safely ignore the 4= since all it does is modify the numbers and we only care about shapes. Then you're doing (10 10⍴a) ∧ ⊂10 10⍴a, and again, the item amount multiplies - 100 × 100 = 10000