@WongJiaHau It is good, but not comprehensive, as modern APL has moved far beyond that with the introduction of nested arrays and additional operators. See apl.wiki/Learning_resources instead.
@Adám Btw I keep making typos and hitting tab to complete a symbol on tryapl.. it switches focus if the character pair before cursor is not convertible. That's kind of frustrating, and it'd be nice to have the option for tab to be no-op when it can't convert.
@goof Ah, that's a good point, and maybe Tab isn't really the right keystroke for it, though I am not sure what else could be used. Problem is that by disabling Tab altogether, keyboard navigation is hampered. Maybe it'd be an idea to give you one "grace" Tab without moving, but then any subsequent Tab does move?
@goof Btw, is your frustration only due to actual typos (you hitting the wrong key unintentionally) or are there substitution pairs that make sense but don't work?
I don't really have any use for keyboard navigation there; to me it could be just like a shell prompt with nowhere to switch focus to. Of course I can't speak for everyone.
(It seems that navigating with tab would be pretty hard anyway, considering all the things it starts cycling through)
the semicolon is there becase i dont understand apl and needed a way to present my problem. I can't find : in the symbols list (meaning i can't read the tooltip/info), what does it do?
Although recently I've also read that the guard style can be converted to a tacit fn, if the left argument isn't referenced: dfns.dyalog.com/n_tacit.htm
atm i try to once a day go through 1 section of course.dyalog.com (only because i can remember the url and I cant spend dedicated time on apl, my goal being to slowly learn the language)
@JosephAdams That's not what I read there, maybe I misunderstood? I think what the link shows is that guards can be written as trains, but the code in the guard is executed twice.
At the moment my workflow is checkout course.dyalog while commuting, so most of it is done via the phone, and the videos are a relaxing way process the information, unfortunately i need breaks inbetween the constant action through out the day :P
Now that guards and diamond came up, I also wanna point out that I learned of this just yesterday (or was it the other day?) when someone posted a recursive solution to my problem. Thing is, tryapl has help for ∇ but both examples use multi-line dfns and you can't enter a multi-line dfn in there.. @Adám
@RikedyP I suspect that it isn't seen as syntax, like parens, brackets, and . in numbers and object access, but really they should all be there. Let's suggest adding {}[](): (which includes ::) and add mention of the other uses to .
But I will try to prioritise some time in the next 6 months to upgrade tryapl a little bit - although it's supposed to encourage people to download the full terp, and people seem to like using it as their only terp
I'll make an issue re: tryapl primer examples and multiline
it'll get resolved either by the enabling of multiline on tryapl or changing the examples
Exactly. But having APL in your pocket for quick calculations in the store etc. would be useful. I end up using my phone for that, but the built-in calculator is anaemic, to say the least.
@rak1507 It's not that hard, really, you just imagine the APL expression for your calculation and then trace through the C code that implements the primitives.
@dzaima or you can do something like ]runtime -r=2s "∘.=⍨⍳1e4" (-r=2s repeating until two seconds have passed, and averaging) if copying in cmpx is too complicated
@RGS yeah I meant exactly the same passage you're referring to: since the IsPrime only needs the right argument I suppose you could do ((0=2∘|){⊃IsPrime/(⍳~⍺),0/(⍳⍺)}⊢)5 for avoiding the guard and statement separator -- but that is 10x more unclear IMO
anyone got a pointer to some resource that shows the difference between the different versions of K? In the (me thinks) latest episode of the ArrayCast Podcast they mention that Whitney thinks of K3-K9 as different languages rather than just different versions of the same fundamental language. But I don't see any major differences...
the builtins definitely shuffle around between each k version, but syntax stays approximately the same. Though k7 did get some unicode characters for a bit of time
@JosephAdams (that wasn't actually about folds, i think those have stayed roughly the same. It's about the overloads of slashes - various iteration stuff, what's encode/decode, and whatever else people managed to squeeze on top of those)
I've suggested that Dyalog does something fun for )erase ⎕io
And in principle it was accepted; just needs someone to implement it.
@Marshall ⍳∘1⍤1
@dzaima Wow. That might actually perform better than the all-grade one, as I suppose ⍉ is O(n) while grade is O(n log n) (or something clever like that)
@Adám The VM does system value lookups so it has this option. But it won't know whether the user is trying to assign •io (which is a syntax error) since the lookup is part of tokenization.
Here's Wikipedia but I think mathematicians basically never say any of this stuff as they are studying the actual permutations and not their representation.
@Marshall also, not quite -- I'm no group theorist, but examining subgroups (of permutations) that have special representations is of interest (famous undergrad exercise: prove the group of all permutations if generated by 2-cycles)
@JosephAdams I think what Marshall meant by "representation" was not the mathematical concept of a representation, but instead the objects we are permuting.
along the same lines one generalizes to "generated by permutations whose structure is X"...though I've no good example on hand for non-cycle representations of permutations
Like Adam just said (10, 30, 20) is a permutation of (30, 20, 10), and Marshall said we don't usually care about the elements themselves, only about the actual permutation we used: (2, 3, 1)
@RGS no, I was also referring to the representation of a permutation (as a cycle etc.) -- I only mentioned group theory as that's where these kinds of "simple" permutations crop up mostly
@Adám You need "permutation which would sort y". A permutation of y is a reordering, but a permutation with no subject is its own thing. Maybe "permutation on ≢y elements" to be more precise.
@Adám so all that matters is that someone who doesn't know the term can understand that they don't know it. And "permutation vector", to someone who didn't know about it, would be synonymous to "permutation"
I'm guessing anyway that nobody's going to rely solely on aplcart and I think grade is best explained with an example call...which the Dyalog terp has anyhow
how does Extended Dyalog APL work, i.e. how does the terp know what symbols to use/parse? is it all just in the name, because wouldn't there be a lot of ambiguity with all the different unicode characters for essentially the same symbols?
@Adám Not in the slightest -- others' APL code is likely better than mine. But I do mind (a bit) relying on experimental/non-universal stuff, and I find the transition a bit awkward between "APL" and a set of user commands that need to be run first in order for my code to work.
@xpqz OK, so it looks like it'll go into Utils, but I notice that in Python's util ~ expands to the user's home dir even on Windows. Do you think it should do that?
Haha, i've seen memes about using emojis as variable names in other languages, but in APL i actually fell for it... so you solution works because it's a prime?
I think im way to tired to grasp this topic for now. I guess I should save this topic for another time. I'll try the rest of the workshop and call it a night soon :( (feeling really tired tonight for w/e reason)
Related: Clearly parenthesize APL trains
Background
In the most basic form, APL has two kinds of tokens: arrays and functions. For this challenge, we will use a lowercase letter a-z for an array, and an uppercase letter A-Z for a function. Furthermore, we will assume each character is a token o...
In APL, you can write tacit functions, called trains. How they work is irrelevant for this challenge. Here are the different ways they can be grouped, using ⍴ as the function:
⍴ -> ⍴
⍴⍴ -> ⍴⍴
⍴⍴⍴ -> ⍴⍴⍴
⍴⍴⍴⍴ -> ⍴(⍴⍴⍴)
⍴⍴⍴⍴⍴ -> ⍴⍴(⍴⍴⍴)
⍴⍴⍴⍴⍴⍴ -> ⍴(⍴⍴(⍴⍴⍴))
...
The order remains t...
From Codidact with permission.
Description
APL trains are a series of functions, that get applied to an argument in this way:
(f g) x = f g x
(f g h) x = (f x) g (h x)
(a b c d e f) x = (a (b c (d e f))) x = a (b x) c (d x) e (f x)
Trains evaluate from the right to the left, so in the last examp...
Is there a short way (in APL that is) to do a 2 f/ but where the windows are disjoint? e.g. 2,/⍳4 ≡ (1 2) (3 4) -- something similar to {(¯1↓(⍴⍵)⍴1 0) / 2,/⍵} but shorter...behaviour for non-even length lists doesn't matter