Currently, you have to use the KAP-specific syntax for defining functions:
You can define a function that takes one left-side argument and two right-side arguments like so: ∇ (a) foo (b;c) { a+b+c }
It can then be called like this: 10 foo (20;30)
I'm considering supporting a←{⍵+⍺} as well. However, I'm not a fan of that because it's inconsistent.
Currently I'm not displaying error messages (you can see then in the JS console though)
Also, I will implement the nicer formatter using HTML tables.
And scroll to bottom, of course.
This is just the absolutely first version that actually runs. I was pretty happy about being able to get that far, so I wanted to upload it right away. Next step is learning React. :-)
And yes, the pretty-printing doesn't show the dimensionality.
Single quote is the symbol quotation character, so 'foo is the symbol foo itself (not its value). So what you typed yielded: the symbol a, the symbol , and the digit 2.
The symbols are prefixed with default: because they are in the default namespace.
If you wanted an array of the character a and the digit 2, you have to type @a 2. Or you can type "a"[0] 2
Because characters are escaped using @. That's something I mentioned before that I'm not happy with and should probably change. It's a bit ugly.
@Adám first, the distribution of lengths of the "unique elements" of a random permutation of the same array, and the second a pattern i noticed in the ≢∪ of a sorted array
@EliasMårtenson 2 2 2 2⍴⍳16 appears to give a single line of output - you still want to <pre> & monospace it
(also the output for it is interesting - i'd expect the 2 2⍴4 5 6 7 to be to the right of 2 2⍴0 1 2 3, but it's below it)
(i was just thinking about this:) https://dzaima.github.io/paste/#0pZPBTsJAEIbvfYpJeAEXBMG3gVgDiXRJC4EjQsJBPaDuJhzUxEQSDz1w4MCBxHfZJ7Gztd1KZ2mVZDrZTmdnu1/@HwCqavplnvWdWkjWgAp4o37H9QMIunzswbg37EKHT9wArrkPV26fe8HQbw973GvfwGDkD3jgBo4SD2rxpMQ0FxuqGMXSUYtn3PbzHqYflJhb6rPonFkUcIaJ6Zc5Ls8x1eOPcc9Lsm2fLD50L1lP51Yx1czcBqaL7FyRbNsmi5XuJeu451WJWyLkPV0X6/ic/3FpYmql/8/wPqx2MheGvJnhzZA3q5/ERVh0sbPUVw5kRasF2yR1t6G0ZpiGOZrhIUd93fS2eFlCW/scvf0hN8Rv1IRiIrS0zdHaHue0I9g4TgW4f/mbUcbYdoPK9d8NKh/LGxR7yxoUe8saNJ5bzqDYaxOifFNySUVoqb/bDVrIpQlRakH6/yUNWsglY9B4bjmDHuNiM6j8PNWghOJIgxqadoPq2xYY1NCzG1TPKTCooXXcoASh1Tc#BQN
@EliasMårtenson that's understandable; you just got unlucky as i was in the middle of thinking about higher ranks :p
@dzaima hm, i still need the arrows for the inner matrices, and the outer cell could be 1×1, bringing me back to step 1, and i kind of want to avoid strong-boxing the outside while possible
more prototype: https://dzaima.github.io/paste#03ZTbSsNAEIbv5ykG@gKuPVjFl1GstKCNJC16qRV6oYLVbqh4AMEDiLlr7hrwXfZJ3N2ck9lI2zths@zM7oSdL39@RNwU5z/p83Elxi5rYQ37w@P9ju2g07VO@3jaG3Rx3zrrOHho2XjQObb6zsDeG/Ss/t4RngztE8vpOACC34rxveAXpTGnknJMQYyngt/osnPBPT3LMRH80pQHtTee4obgI2RyiuKGipthrM/w57gsiBfvFfmwZiSpyKkevVcuW2rayr6Xx2V@vHioyMuaN7p/99rA5Rsq@v@LS1vddzvhwlQ/rL42F6Z4M5ZwYYo3a67FZWbof2HIPwFmVasV2yZ1N6e0lrLzSjS9IkfdbkJRNUtoKyjRC4rcFP5UTUpMhJb8Ei2/mtOCZsMkk90MnAZk1FIYE9D3IMU00nv5nyzM0SKJ9nI/T5QjP77a49Sl1HbYSO4jNyrMZQpLmgUsaQKwmoifAKCGlr2TF23GakG4XN3anZTGJ5WUY2Z2TPfOlAe1l4MQxqljRmdIKOZ8WJOFFcapY8ZnKHjmv…
@Adám lstlisting is a pretty useful package, so I guess it is a matter of testing it and, if it works, yes
@EliasMårtenson If it is not much trouble, yes please. Can you link me to it? Or how would you rather do it?
@RGS I found this link when I was first trying to get APL to work with latex, but when I found this link I didn't understand the problem well enough and so I couldn't check if what the link suggests is good or not
@ngn that's just a side-note of mine (more an inconsistency that i assume isn't intentional). With APL syntax to allow assigning functions, though, it does take separate "syntax" unless your assignment is overly generic (at which point you risk allowing incredibly stupid things that dzaima/APL allowed - a←← would assingn ← to a and a←[2] would assign the internal temporary bracket object :P)
yay it works https://dzaima.github.io/paste/#07VrBasMwDL37K0K/YOt27EfsJ/YDo5fdshRy2AYri0MD6S5bexjtrb0lsH/xF@wT5jmNI3DimNkUMQQKdWRZeVIdPQsSRZGI32/ubufz@2gq4q/@a/s4m3y/5Z8TJviLSF8Ff0AgBxwwpGQyL4sQqfEPKUOFROUlzcYAHbxDcvGACAkDgJ6Vu1jJvh1IWSob@2wID5iQMAioKTmCJ3pg0/usOvsTQZx8DTJRg/HGYTaUByxIYF6Sgfwl1n/yb6vO/UQYJweZOIJx4TAbygMWJDovH7Yqmj9Za@wukAdESOB@8a/2IfgCBxLiC@IL4gviC76yVtHKOlsG8oAICRsnHhcZIScX2aFCovcLjn4UDRLqR@l8QecLOl/Q@YL6UepHiS@IL4gviC@oHw3bj668e7jK20OJCgkLASWUVGiQlCyCHybM9FcI7UCk@TX7JeTuJbTLkqnyBRnc5HHN5omy7hrIvZ7o0zTWasGF/LnsveusTjRSt9TRq@msk6m8rgbutBUHRakY0Jys10bEtaHZQN//MAfciPhoaIrGmjv…
@dzaima (but just the array formatting is already 160lns, 5800 chars of java :/)
@dzaima OK, here's the deal. ← assigns values. A bare {1+⍵} is not a first-class value, it's a function. A first-class function closure has the syntax λ{1+⍵}.
So that means that ← would end up assigning a value if the right-hand side is a value, or it would act as a function declaration if the right-hand side happens to be a function.
KAP needs to be more strict than Dyalog here since it parses everything into an AST up front
I've noticed the following error: Could not load bridge interface functions. (Error 0x0065ebc8: "image not already loaded") whenever I do a ]LINK.Create -- although the link seems to work from what I can tell.
Whenever I get a WS full error it's probably because I'm doing something stupid, and the error makes me think about what I'm doing, which normally leads to a better solution
That's mostly because currently I've based a lot of my work on the ISO spec, which doesn't include operators with arguments.
@dzaima True, but the issue is that just like ISO, I currently don't have a way to handle operators with arguments. The ∘ is a very poorly defined special-case in the spec.
Ahh, I'm so annoyed, I've been confused about why my answer to a project euler question was wrong, and it's because I pasted in ¯number, and it wants -number
@EliasMårtenson what are you trying to achieve with this implementation? if you don't stay focused, if you keep saying yes to everything, you'll probably run out of resources and motivation rather soon.
@EliasMårtenson in many languages functions can change. a function is just a name-value association whose value happens to be a functional object, just like an ordinary variable
Let's say I have a loop. Going into the loop A is assigned the scalar 10. Now, in the loop, there is the following instruction: foo a b. The parser parses this as (call foo (args: a b)). However, later in the loop, a is assigned to be a function. The next time around you'll still call foo with the two arguments a and b.
This is because the code is parsed once: At function declaration time.
@xpqz Quite the opposite. Windows comes with .NET Framework, so it doesn't really need Core. Link is looking for .NET Core and the status window is a side effect of looking for it. Safe to ignore. Feel free to log an issue complaining about it.
The function gets the lexicographically largest entry from a mixed-type table, and that was only added in 17.0. Try APL runs 16.0, but we're working on upgrading it.
However, if I don't have the λ syntax, then how would you define, say, an array of mixed numbers and functions. I can do foo ← 1 2 λ{⍵+200} 3 4 λ{⍵+100} 5 6
Without λ how can I achieve that?
That's an array of 8 values. 6 numbers and two functions.
@rak1507 Pretty sure there isn't any easy equivalent. You're going to have to write some loops/maps. There are functions that will give you each individual coordinate (e.g. 1⊃¨⍳10 10) if you're able to use that form.
@dzaima Fair enough. But once you have the ⎕OR, how do you call it? It's not clear to me from the documentation. If you do x ← ⎕OR{⍵+200}, can I simply call that function like so? x 10
@dzaima Which is arguably an implementation bug. The fact that variables vanish when the containing function returns is completely unspecified as far as I know.
@EliasMårtenson Function ⎕ORs turn into functions when used as operands, so a convenient trick is x∘⊢ 10.
@Marshall Cool, I never knew that worked other than with dops. No particular reason why there'd be a difference, but I simply didn't think of it. Thanks!