« first day (1059 days earlier)      last day (1585 days later) » 

12:00 AM
Hahaha I was going through the phase 1 problems for 2013s dyalog competition
and the last question is literally just "what does ⌹ do"
 
 
4 hours later…
4:20 AM
And here comes a win against myself.
 
 
5 hours later…
9:41 AM
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.
 
9:56 AM
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?
(rather than "that's a syntax error")
 
@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 they really are different languages, eh. Is each not considered "an explicit loop"?
 
@TessellatingHeckler I'm not sure what you mean by that question.
 
10:16 AM
@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
 
@TessellatingHeckler Ah yes, then ¨ is an explicit loop. So is really, but it can use tricks to sped up certain things.
 
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?
 
@TessellatingHeckler You know about APLcart, right?
@TessellatingHeckler What he meant was that it doesn't explicitly loop to process the cells one-by-one.
 
@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 It is a later addition from NARS (Nested Array Research System).
 
10:26 AM
Delay is right there!
(I ended up with {⍺,' ',⍵}/'abc'
 
@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.
 
@Adám ahh, that makes sense - no x,y coordinates looping over the cells and doing neighbour counts!
 
@TessellatingHeckler Yeah, also the ¨ is very limited — "O(3)".
 
(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" :)
@Adám "O(3)" - constant runtime?
 
@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).
 
10:36 AM
@Adám interesting; faster because no dfn/user function calls?
 
@TessellatingHeckler No, faster because no nested arrays and no prepending data.
 
@Adám not quite following; where are the nested arrays?
the intermediate ('a', ('b-c'))?
no that could be simple
appending data, I can see being faster depending on internal design
 
@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).
 
@Adám 🤦‍♂️ oh why is it nesteddddd
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):
⍞←¯1↓,'-',[1.5]⍨'abc'
 
10:52 AM
@Adám a-b-c
 
This has only one memory copy and done, instead of two.
@TessellatingHeckler Oh, and of course, / has to actually loop, while , uses Marshall's magic.
⎕←⎕SE.cmpx '⊃(⊣,''-'',⊢)/a' '1↓,''-'',⍪a' ⊣ ⎕SE.a←1e4⍴⎕A
 
@Adám
  ⊃(⊣,'-',⊢)/a → 1.4E¯1 |    0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  1↓,'-',⍪a    → 0.0E0  | -100%
 
⎕←⎕SE.cmpx '1↓,''-'',⍪a' '¯1↓,''-'',⍨⍪a' '¯1↓,a,[1.5]''-''' ⊣ ⎕SE.a←1e4⍴⎕A
 
@Adám
  1↓,'-',⍪a      → 2.9E¯5 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  ¯1↓,'-',⍨⍪a    → 1.9E¯5 | -34% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  ¯1↓,a,[1.5]'-' → 1.3E¯5 | -55% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
 
@TessellatingHeckler ^ I'd say 4 orders of magnitude is a reasonable speed-up.
 
11:05 AM
@Adám *thinks .. rho is the shape, rho rho the rank .. so the rank of a character vector is 1 and has to reduce to 0
 
@TessellatingHeckler Actually the ≢⍴ is the rank.
 
@Adám I shouldn't trust poetry or song for programming language details.
@DyalogAPL in these graphs, are the quad-blocks getting longer to represent more time taken? the shorter, the faster?
 
@TessellatingHeckler Well, when that was written, didn't exist yet.
 
@TessellatingHeckler The first one is a baseline. The rest are relative to that. The longest runtime always has 40 quads.
 
@Adám is that a module I can load? ⎕SE.cmpx is a VALUE ERROR right now
 
11:12 AM
Dyalog APL answer the question in english too?
 
@RosLuP I think it's only a matter of time before that's common ;)
 
@RosLuP Sì.
2
 
Dec 12 at 13:18, by Adám
Announcement: The chat bot now has the dfns workspace loaded into ⎕SE (when using ⎕← or ).
You can 'cmpx'⎕CY'dfns' or )copy dfns cmpx or simply use ]runtime -c "expression" "expression"
 
@Adám I can )copy dfns cmpx and something happens (a filepath and workspace saved) but ⎕SE.cmpx isn't a thing, still
 
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←
 
11:20 AM
@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.
@Adám a Mechanicapl Turk
 
@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 Yes, but you don't have to (and shouldn't, imho) )save.
 
@Adám why "shouldn't" )save ? does something autosave?
 
@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?
 
11:37 AM
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
 
@TessellatingHeckler Lesson 16 - APL objects: namespaces at your convenience. Sleep well!
 
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)
@Adám Thank you!
 
@TessellatingHeckler All that should be possible, but get some rest. I'm here next week too (just a bit less).
 
 
2 hours later…
2:06 PM
Can someone give me a quick rundown of how ⍣ works?
 
function ⍣ number of times to operate ⊢ data to operate on
⎕←⊂⍣5⊢('abc' 'def')
 
@JamesHeslip
┌─────────────────┐
│┌───────────────┐│
││┌─────────────┐││
│││┌───────────┐│││
││││┌─────────┐││││
│││││┌───┬───┐│││││
││││││abc│def││││││
│││││└───┴───┘│││││
││││└─────────┘││││
│││└───────────┘│││
││└─────────────┘││
│└───────────────┘│
└─────────────────┘
 
Essentially I've performed the nest function 5 times on my data
You can also perform inverse operations by negating the quantity
 
Oh ok
what is the thing for getting the index of something in a simple list?
 
dyadic ⍳?
⎕←'abc' 'def' 'ghi'⍳⊂'def'
 
2:13 PM
@JamesHeslip
2
 
yeah that works
thanks
 
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.
⎕←2⊥⍣¯1⊢81
 
@JamesHeslip
1 0 1 0 0 0 1
 
⎕←2⊤81
 
@JamesHeslip
1
 
2:19 PM
⎕←2 2 2 2 2 2 2⊤81
 
@JamesHeslip
1 0 1 0 0 0 1
 
Otherwise we need to work out exactly how many bits will be in the result before calculating the result :)
 
I'm trying to 'trainify' this function but failing, any tips?
{⍵⍳⍨+\+\⍳⍵}
 
2:34 PM
⊢⍳⍨+\⍣2∘⍳
Or better: +\⍣2∘⍳⍳⊢
 
What does ∘ do in that?
 
f∘g is do g, then do f. (composition)
 
does it do f with the result of g?
 
Yeah, (f∘g)⍵ is f g ⍵
 
oh ok, didn't know that
I'm guessing ∘ is really useful for trains
2
 
2:41 PM
Exactly
 
I was trying to use brackets to make a 2 train in the middle of it but you can just use that
 
3:00 PM
@H.PWiz I was doing that for a solution for this, do you want to post it or can I?
 
Feel free to post it :)
 
thanks :D (I'll credit you ofc)
how do I do function submissions on TIO?
(using the header and footer)
 
3:18 PM
ok thanks :D
 
@EdgyNerd @H.PWiz I prefer f←⍎⎕IO⊃¯3↑⎕SRC⎕THIS in the Footer as it allows inserting preparatory code in the header, and also allows changing ⎕IO to 0.
 
 
2 hours later…
5:00 PM
can someone give me a (slightly) complicated train challenge for practice?
 
 
2 hours later…
6:55 PM
@EdgyNerd: How about: A list of all the unique elements on the outer edges of a matrix
 
 
1 hour later…
8:22 PM
could someone walk me through how you'd do something like that?
I kinda have an idea but not really
(I'm really awful with matrices stuff)
 
8:41 PM
My guess would be to start with the fact that all elements on the edges of matrices have at least one index that is 1 or the length of the matrix
 
9:15 PM
can someone explain why this doesn't work for that?
⎕←(⊃,⊃∘⌽)∪∘,(⊃/,⊃/∘⌽/)
 
@EdgyNerd
  ┌─────┼──────┐
┌─┼─┐   ∘    ┌─┼─┐
⊃ , ∘  ┌┴┐   / , /
   ┌┴┐ ∪ , ┌─┘ ┌─┘
   ⊃ ⌽     ⊃   ∘
              ┌┴┐
              / ⌽
            ┌─┘
            ⊃
 
(it gives a rank error)
 
@EdgyNerd ⊃/∘⌽/ is interpreted as (⊃/∘⌽)/
 
oh right
how would I reverse each row of a matrix?
 
@EdgyNerd just
 
9:19 PM
⌽ reverses each row, ⊖ reverses the order of rows (or reverses columns, if you prefer)
 
it's still giving a rank error so I'm kinda confused
 
@EdgyNerd what's your current code?
 
⎕←(⊃,⊃∘⌽)∪∘,(⊃/,⊃/∘⌽)
 
@EdgyNerd
  ┌─────┼──────┐
┌─┼─┐   ∘    ┌─┼─┐
⊃ , ∘  ┌┴┐   / , ∘
   ┌┴┐ ∪ , ┌─┘  ┌┴┐
   ⊃ ⌽     ⊃    / ⌽
              ┌─┘
              ⊃
 
oh is ⊃/ meant to get the first element of each row?
 
9:23 PM
yeah
 
I think thats the part thats throwing the error
⎕←⊃/3 3⍴⍳9
 
@frank
RANK ERROR
 
@EdgyNerd ⊃/2 2⍴'abcd' does ('a'⊃'b')('c'⊃'d')
 
how would I get the first element of each row?
 
you want ⊣/ I think
although that might mess with the train, not really sure
⎕←⊣/3 3⍴⍳9
 
9:25 PM
@frank
1 4 7
 
yeah that'll work
 
@frank it'll mess with trains as much as ⊃/ does, but the alternatives (1↑⍉A, ⊃¨↓A, (≢A)1↑A to name a few aren't better)
A[;1] is another alternative to get the first column, but you're definitely not getting that in a train
 
yeah it isn't working
I might just rewrite it in a different way because the way I'm trying is kinda dumb
 
@EdgyNerd i've got 18 bytes adapting your method
 
as a train?
 
9:33 PM
not as a train is ok
 
@frank yeah (excluding the outer parenthesis)
 
could you give an input with an output so I can test mine?
 
@EdgyNerd 4 5⍴⎕AABCDEPQRSTJOFK
 
whenever I try something it always only gives 2 results
I'm guessing that I'm doing something wrong here
(⊃,⊃∘⌽),(⊃,⊃∘⌽)∘⍉
 
@EdgyNerd ⊃4 5⍴⎕A is just 'A'
 
9:41 PM
what happened to ∪
 
i'm really confused what I've done
 
down to 16 chars
@EdgyNerd instead of you should use ⊣/ to get the first column (and ⊢/ is also useful for last)
 
⎕←(⊣/,⊢/)∪∘,(⊣/,⊢/)∘⍉4 5⍴⎕A
 
@EdgyNerd
AT
 
@EdgyNerd you need to wrap the train in parenthesis
 
9:45 PM
⎕←((⊣/,⊢/)∪∘,(⊣/,⊢/))∘⍉4 5⍴⎕A
 
@EdgyNerd
ABCDEPQRST
 
is that right?
wait oops
⎕←((⊣/,⊢/)∪∘,(⊣/,⊢/)∘⍉)4 5⍴⎕A
 
@EdgyNerd
AFKPEJOTBCDQRS
 
@DyalogAPL that is indeed correct
 
oh wow
how did you shorten yours so much?
 
9:46 PM
yours is 19 bytes
not including the outer parentheses
 
oh yeah I guess it is only 3 bytes shorter but still
I'm kinda curious
 
consider that you can take the first and last rows instead of transposing the matrix
 
@EdgyNerd can be somewhere else, and you can get rid of one pair of parens
 
⎕←(∪(⊣/,⊢/),(⊣/,⊢/)∘⍉)4 5⍴⎕A
 
@EdgyNerd
AFKPEJOTBCDQRS
 
9:53 PM
⎕←(∪⊣/,⊢/,(⊣/,⊢/)∘⍉)4 5⍴⎕A
is it that?
 
@EdgyNerd yep. my solution was (∪(⊢/,⊣/)∘⍉,⊢/,⊣/), but order doesn't matter so that works too ¯\_(ツ)_/¯
 
oh wow
does removing the brackets work because it treats it as a 4 chain
which is the same as a 2 chain with the second thing being a 3 chain?
 
@EdgyNerd it's just a 3-train (fork) with the 3rd part being another fork.
 
⎕←++++
 
@EdgyNerd
┌─┴─┐
+ ┌─┼─┐
  + + +
 
9:57 PM
oh ok
that kinda makes sense
 
I had the idea of shortening it more by doing something like
(∪∘(⊣/,⊢/)(⊣,⍉))
(basically combining the transposed and the original into an array and then doing them both on the left thing, but it didn't work)
 
@EdgyNerd i tried that but the best i got was {∪⊃,/(⊣/,⊢/)¨⍵(⍉⍵)}
i got 12 bytes by a different way of achieving function reuse though :D
 
oh wow
does it involve the right (⊣/,⊢/) ?
 
@EdgyNerd It's still there, the question is more about the left (⊢/,⊣/)
i don't know if this code can still be called a train
 
10:07 PM
I'm kinda stuck on how to shorten it to that
 
@EdgyNerd eh, that's expectable if you don't know the trick. solution
 
ohhh right
that makes sense
also that technically is a train
 
@EdgyNerd the result definitely is, and i guess just code can't really be called a train, so probably.
 
10:49 PM
⍞←(∪⊢⌿,⊣⌿,⊢/,⊣/)4 5⍴⎕A
 
@voidhawk PQRSTABCDEJOFK
 
oh wow
12 bytes without the assignment
what does ⌿ do?
 
"Reduce first", so while / works on the last axis, ⌿ works on the first
For a matrix, that means it operates on the columns
 
oh ok
 
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
 
10:59 PM
that looks pretty optimal
(and it's also a lot simpler)
 

« first day (1059 days earlier)      last day (1585 days later) »