f←{name←⍞ ⋄ 'Hello ',name} hopefully makes a niladic function, but writing f prints ∇f instead of running it; is there a way to invoke it other than providing a dummy right argument like f 0?
@TessellatingHeckler No, Dyalog APL does not allow niladic dfns. That would create ambiguity: Does x←{?10} make x a random number or a niladic function that returns a random number?
However, NARS2000 does allow niladic dfns (they're not really functions then, are they?), with the odd effect that x←{?10} and x←({?10}) makes x a function and a variable respectively, thus breaking the rule that parenthesising a syntactically valid phrase makes no difference.
@Adám ah, yes that would be ambiguous. so what does f←{name←⍞ ⋄ 'Hello ',name} do in Dyalog APL? It doesn't prompt me to enter something, and it creates f as a namem of something?
NARS2000 might be where I was trying it, I still test in that a lot
@TessellatingHeckler Right, the content of a dfn doesn't matter at assign time, until it is invoked. When given a (dummy) argument (or two), it will prompt, and return.
the scrollback here, on the trad-fns, is very interesting. I have been wondering about the header line and whether it could bind multiple names from the right argument (as I used to think), or whether the extra names were local variable declarations (as I read recently), but apparently it's both
@Adám wait, so "Dyalog APL does not allow niladic dfns" means, you can do that, but technically it's not niladic, it's monadic, it just doesn't use any argument?
@TessellatingHeckler In Dyalog {?10}¨'hello' makes perfect sense. In NARS2000 {?1}¨'hello' gives a two element vector result even though constant¨ is not valid!
@TessellatingHeckler In other words: In Dyalog APL, all dfns are ambivalent (can be used monadically or dyadically) no matter if ⍺ and/or ⍵ appear inside.
@Adám that was unrelated; since reading somewhere in the transcripts here from a long time ago, that one can tell something about code performance - the more "eaches" it has, the slower it is. Since then I've tried to rewrite code with tabling and multiple dimensions, to see if I can avoid "each", considering it less-APL-ish. Just like foreach ($x in $things) { f $x } is an explicit loop, or $things | foreach { f $_ } in PowerShell
anyway, I wanted to loop something, using the power operator, with a delay; and I couldn't remember how, and couldn't think how to find which QUAD handles delays. But I could remember where I got the idea - the Conway's Game of Life video in APL on YouTube, and I watched it through again just to be amazed again
, and there's a moment saying "this line for the next generation is a single array expression and you'll notice that it contains no explicit loops and no temporary variables"; and I thought "eh? but it contains rotate each?". And then carried on watching and got to ⎕DL for delay
just seeing you write {?10}¨'hello' got me back to wondering, is "each" considered an explicit loop, and how "APL-y" is it? Is it from the early days, or a more recent convenience add-on?
@Adám Yes, although I don't think to look in it often (yet); last time I tried I wanted an equivalent of 'a', 'b', 'c' -join '-' giving 'a-b-c' and was looking for string join, join, but didn't find anything. Most of the entries are way too mathematical for me to understand
@TessellatingHeckler That's correct. Btw, I'm not claiming APLcart has everything (yet), so when you find something generic like that missing, please PR/log issue/tell me.
(and then made it (⊣,('-',⊢))/'abc' and (⊣,'-',⊢)/'abc' which was a pleasing "Ah! I get it!" train minor success)
@Adám I don't know how generic it is, whether there's likely to be an idiom for it; I don't expect APLCart to be "how to write all code for all things" :)
@TessellatingHeckler If the list is simple, like 'abc' then 1↓,'-',⍪'abc' is shorter, and ¯1↓,'-',⍨⍪'abc' is faster
@TessellatingHeckler No, it triples the runtime, rather than a factor depending on world size. I guess O(3n) would be more correct, or for the entire algorithm, O(9n) which is of course just O(n).
@TessellatingHeckler In this case, there's only one nesting, which is the result.
@TessellatingHeckler ⍪ is either free (just change internal shape; data stays as-is) or RAM copy speed. '-',⍨ is again a RAM copy. ¯1↓ is free (just change internal shape).
can't think what else I could run to see if I should have expected that; plus-reduce over a vector of integers doesn't nest the result .. although maybe it does because (1)≡(⊂1) is 1
oh well, thank you as always, about the dfns and the APLCart and so on
@TessellatingHeckler Exactly. The rule is that a reduction always reduces the rank (hence the name). If the result isn't a simple scalar, that means an additional level of nesting.
@TessellatingHeckler Oh, even better (speed-wise):
Did you guys seriously think an APL interpreter could participate in a chat room? Obviously, it is one of Dyalog's employees keeping an eye on the chat, quickly copying any APL expressions to his interpreter, and pasting the result here ;-)
@TessellatingHeckler No, it copies the function to your current namespace, which is # by default, so you can just use cmpx without ⎕SE.
Anyway, you probably want cmpx in the namespace you're working in, as otherwise it won't access your variables. Notice the ⎕SE.a←
@Adám I noticed the ⎕SE.a← after it took me into the debugger a couple of times, and I edited it out; I now see results! 0%, -20%, -30% on this machine
@Adám I haven't touched workspaces yet, just been starting from wherever it opened or CLEAR WS every time.
@TessellatingHeckler Workspaces are mainly a relic these days. Save your stuff in text files, and work in a CLEAR WS. However, you can change the ⎕WSID to keep your windows apart. However, namespaces are important. Are you familiar with those?
@Adám "namespaces are a honking great idea, lets do more of those" is in the Zen of Python, if I remember rightly; generally yes PowerShell has a using namespace idea in it
⎕WSID changes the titlebar; presumably that's where it would )save to
@TessellatingHeckler Because )save (and ⎕save) creates a binary file containing your root namespace. If you instead save to text files, you can use SCM. And both SALT (old text file based system) and Link (new system) will save to file whenever you save in or close the editor. SALT even has rudimentary SCM built in.
If you save your stuff as text files, (unscripted) namespaces are saved as directories, so you can use your favourite file system browser and tools to navigate and move stuff around.
@TessellatingHeckler Sure, but do you know how to use them in APL?
Save icon in the menu, no that's for workspaces. Unclear if I can change the type to 'all files' and have it do anything useful. File -> Save As, also for workspaces. Session -> Save As, no that's something else. )ed a name, no save there only fix. File -> Edit Text File will try to open a .dyalog file, but won't create one that doesn't exist
@Adám I don't, but I have to go to sleep and be awake in <7 hours, so I will have to remain ignorant
File -> Export -> .Net Assembly 👀 oh hey, it must be possible to build a PowerShell cmdlet with that(?); (It would need to reference System.Management.Automation and be a class which inherits from PSCmdlet, and maybe deal with those attribute things)
2⊥⍣¯1 is a good example of inverse operations using the power operator
The inverse of ⊥ (decode) is ⊤ (encode)
Decode takes a scalar, while encode takes a vector left arguement. By using this neat little trick we can utilise scalar extension to do an encode operation.
There are a few functions with that hyphen overstrike that have similar differences, like ⌽ is reverse last and ⊖ is reverse first, or , is concatenate last and ⍪ is concatenate first