« first day (1540 days earlier)      last day (1117 days later) » 

3:50 AM
Just double clicking on the function name right in the session will bring up the editor, no need to type )ED
Or shift+enter when your cursor is over it
 
4:21 AM
These aren't "official Dyalog best practices", but there's some good information here on best practices for writing APL application code: https://github.com/the-carlisle-group/Dado/wiki/How-Not-To-Code-In-Dyalog-APL
That repo is also a 3rd party DevOps framework for APL, which also has useful information in the wiki for a Git workflow that works well for some APL projects.
 
 
5 hours later…
9:48 AM
Is there a secret way to do block comments, or do I have to precede each line with the lamp?
 
none
(heh, _←{1\n whatever \n comments \n}0 kind of can maybe work if the comments are tokenizable as APL :P)
 
 
1 hour later…
11:13 AM
Is there an easy way to take a string and turn it into a list of codepoints?
 
⎕UCS
 
ah, thanks. is there a good full list of functions anywhere?
 
@hyper-neutrino reference card is the first thing that comes to mind
 
oh that looks very convenient. thanks
also what site/editor would you recommend for apl? i'm just using tryapl.org right now and also just noticed that UCS is literally on the page i just didn't scroll or ctrl-F the right thing
 
also APLcart
(@Adám "string" would be a good keyword for ↑)
@hyper-neutrino tryapl is the best online thing there is (TIO is of course outdated)
 
11:19 AM
ah, okay.
hope y'all don't mind how many questions i'm going to have :P how do you make a vector/list/? of strings? i tried looking this up and can't seem to actually find an answer so idk what i should be searching for
 
generally, just item1 item2 item3 …; you may need to parenthesize the items if they're not single tokens
(also note about tryapl - at the bottom there's an input field separate from the history log, which is a more traditional REPL (up&down arrows work) if you want that)
 
i'm trying to make a list ["BG", "CA", "FI", "OK"], and i've tried 'BG' 'CA' 'FI' 'OK', putting brackets around each term, that but with double quotes, and all of them give a syntax error or say "NOT PERMITTED: Illegal token"
 
the "illegal token" message must be from something else
'BG' 'CA' 'FI' 'OK' alone works for me on tryapl
 
@dzaima Done.
 
'BG' 'CA' 'FI' 'OK'{⎕UCS} says missing right argument
 
11:27 AM
@hyper-neutrino Only ' is permitted for character data. Never ".
 
{⎕UCS}'BG' 'CA' 'FI' 'OK' says syntax error
 
@hyper-neutrino Just ⎕UCS without braces.
 
@hyper-neutrino ↑ and you also want ⎕UCS¨ 'BG' 'CA' 'FI' 'OK'
 
{} forms a user-defined function wherein the right argument is denoted .
 
ohh. okay, i see. i think i vaguely remember that
is alpha the left arg?
 
11:29 AM
It is.
Right-most and left-most letters of the Greek alphabet.
 
cool :D
@dzaima ah, right. that fixes the Domain Error i was getting
wait, does APL not have just a basic sort? aplcart seems to be suggesting i grade up and then like index in or something
 
yep, you have to do {⍵[⍋⍵]} or whatever
 
nope, clearly matrix inversion is a much more common operation and therefore worthy of a primitive
 
lol rip
 
@rak1507 More like: grading is the fundamental operation underpinning sorting, so we have that instead.
There's currently a major discussion going on internally at Dyalog about a sorting primitive.
 
11:40 AM
oh, cool
 
Some hold that Dyadic should be re-purposed to be "sort by".
This would make ⍋⍨ into "sort".
 
yeah, that would be nice
 
Others hold that the problem is really with and that adding a "reorder" function, e.g. would solve the problem as ⍋⊇⊢ for sort.
Some thing that a dedicated sorting function would be worth-while, despite the existence of Grade. Monadic and < and have been suggested.
 
is there a better (by which i mean shorter) way to write {⍵,⌽¨⍵} using compose or something like that?
 
Of course, this wouldn't give you a "sort by".
 
11:43 AM
⊢,⌽¨
 
Or ,∘(⌽¨)⍨
@rak1507 For a newcomer, you probably want to write that (⊢,⌽¨) to avoid frustration.
 
good point
 
yeah, it wasn't working so i randomly guessed to bracket it :P
 
lol
 
@Adám I think "sort by" should probably be left as 2 separate things. Means there's less incentive to do stupid stuff like (s⍋a) (s⍋b) which would have to sort twice
 
11:45 AM
@Adám why is the swap here necessary as in why does ,∘⌽¨ not work on its own?
 
(,∘⌽¨) x = ,⌽¨x
which is not what you want
 
@hyper-neutrino It isn't swap, but rather "self". You want the argument as both left and right argument, so you get x,∘(⌽¨)x
 
@rak1507 no, it's ,¨⌽¨x
 
oh yeah
 
@hyper-neutrino Btw, {⍵,⌽¨⍵} is perfectly good APL code.
 
11:47 AM
@Adám ah, that makes a lot of sense, thanks
@Adám oh cool, good to know :)
so {(⍳⍵)~⍳⍺-1}/¨⎕UCS¨(⊢,⌽¨)'BG' 'CA' 'FI' 'OK' is giving me a list of lists, half of which are empty, as i expected
how do i go about flattening that? i tried putting ,/ at the start but it doesn't seem to work exactly how i wanted
 
⊃,/ or ∊ depending
 
oh worked perfectly
 
@hyper-neutrino f/vector has an implicit that you don't want, so you really have a list of lists of lists there that you want to flatten
 
@hyper-neutrino Getting used to searching APLcart is a good idea…
 
@Adám true. i'll eventually get used to the keywords
 
11:53 AM
The behaviour of f/ may seem strange, but notice that it is called "reduce" because it reduces the rank of the argument. So a vector must become a scalar.
 
i looked up flat and thought the first one (ravel) was what i wanted cuz like
reshape into vector
 
@hyper-neutrino No no, if whatever you feel is natural to search for doesn't give you the desired result, please let me know so I can fix it!
 
@Adám the thing i wanted (enlist) did show up foruth when i looked up flatten, i just got caught up with trying to get ravel to work and didn't go back and look for other things that might suit my needs :P
 
Ah, ok.
 
for getting the differences between adjacent elements, how does (+\⍣¯1) work exactly? specifically, i'm a bit confused about exactly how functions
 
12:01 PM
it's Magic™
 
@hyper-neutrino (f⍣¯1)X tries to find any value of Z such that (f Z)≡X
 
oh wait is just function power?
 
@hyper-neutrino It is.
 
oh okay, that makes a lot more sense
not used to a programming language being able to just take function power ^ -1 and just get an inverse, lol
 
:-D Some of the things it can do are pretty cool.
 
12:05 PM
damn, you can do +\⍣¯1, I was doing that exact thing yesterday but I did ⊃,2-⍨/⊢ instead
 
⍣¯1 (and under) are my favorite APL things
 
yeah being able to take arbitrary function inverse is really impressive :o
 
It can't quite handle any arbitrary function, though.
 
doesn't work on dfns
 
@rak1507 most
 
12:06 PM
what dfns does it work on?
 
@Adám I'd call those bugs
 
Some trivial ones, like {⍵} and {⍺}.
 
oh
well that's boring
 
@Adám I wouldn't say "quite". For a function to be invertible, it has to be tacitly defined with a single path of the argument (or in the case of dyalog, alternatively be numerically solvable, but that's boring)
 
This is fun:
        4 ('ab',2+×⍨⍤,) ⍣¯1 ⊢ 4('ab',2+×⍨⍤,)10
10
@dzaima I meant that "quite" as an understatement in reaction to HN's statement.
 
12:11 PM
holy crap I just discovered something incredible
{|+\⍣(-⍵+2)⊢⍳⍵+1}
pascals triangle
 
how do i write {(~⍵)⊂⍵} more concisely? i tried (~∘⊂)⍨ and composing the other way but neither seems to work
 
@hyper-neutrino (~⊂⊢)
Non-train alternative: ⊂⍨∘~⍨
 
okay; the first one kind of makes sense i think (is it a monad-dyad-monad chain such that it returns g(f(a), h(z) for f g h?)
i'm a bit confused about how the second one works though
 
@hyper-neutrino Correct.
@hyper-neutrino The lefthand swaps argument order of and the righthand applies the function with the single argument on both sides.
⊂⍨∘~⍨YY⊂⍨∘~YY⊂⍨~Y(~Y)⊂Y
 
oh, so the last applies to the whole thing, not just the ~?
that makes a lot more sense, thanks
 
12:23 PM
Yes, operators (higher-order functions) have long left-scope.
 
okay thanks for all the help i really appreciate it :D i'm trying to submit to this question and rn what i have is -∘1⌈/≢¨(~⊂⊢)1=(+\⍣¯1){⍵[⍋⍵]}∪∊{(⍳⍵)~⍳⍺-1}/¨⎕UCS¨(⊢,⌽¨)'BG' 'CA' 'FI' 'OK'
what would i need to submit for that to be a valid submission
 
Can probably be golfed a bit, but the simple thing would be {-∘1⌈/≢¨(~⊂⊢)1=(+\⍣¯1){⍵[⍋⍵]}∪∊{(⍳⍵)~⍳⍺-1}/¨⎕UCS¨(⊢,⌽¨)⍵}
 
okay, perfect. i'll work on golfing it over time. thanks a lot :D
 
12:57 PM
CMC: Given a vector Nv, find a numeric vector Mv such that Nv≡2+/Mv
 
@rak1507 shouldn't AZ give 26?
actually, i guess it should be passed as ⊂'AZ' in which case it gives the correct answer nvm i misread
oh i misunderstood, the question's asking for the path length not the number of letters encountered
@Adám surely you can take advantage of the fact that the input ∊⎕a instead of spanning the whole of ⎕ucs
 
1:21 PM
+500 rep to the shortest vanilla dyalog apl answer under 30b (i.e. competing with rak's extended answer) to codegolf.stackexchange.com/q/223464 . the way in which it will be rewarded is that once i notice someone posting an answer under 30b, i'll start a bounty, which i will award after a few days to the then shortest answer
2
 
 
1 hour later…
2:39 PM
@user41805 Lots of golfs possible there, many of which are "obvious" to the experienced golfer. I was just answering HN how to "package" the formula into a function.
 
3:00 PM
@brgal Not sure why you removed your message, but do you know about var,←?
 
I want to simulate random typing.
pic←''
⎕ED 'pic'
{pic∘←⍵ ⋄ ⎕DL 0.3}¨,\(27↑⎕A)[?60/27]
Is there another way to do that?
@Adám No I don't know about it. Just checked aplcart.
 
@brgal Do you specifically want it into the edit window, or is into the session OK?
 
In the edit window, because I want the simulation to resemble what we can see on a screen if a monkey types on a keyboard.
One letter after one
For now my code is OK but does not handle newline
I wonder if it is possible to modify slightly the code to force a new line after 50 letters on a row.
 
3:16 PM
@brgal Always after each 50, or random length lines?
 
random length lines could be also fine
 
pic←'' ⋄ ⎕ED 'pic' ⋄ {pic,←⍵ ⋄ ⎕DL 0.1}¨60{⍵[?⍺/≢⍵]}⎕A,⎕UCS 10,4/32
 
Thanks @Adám !
 
@user41805 damn, under 30 is hard
 
3:31 PM
ooh: just discovered an interesting way to fill gaps, CMC: given a boolean vector with two 1s, fill the gap between the 1s
0 1 0 0 0 1 0 -> 0 1 1 1 1 1 0
 
@rak1507 ⊢∨≠⍀
 
yep, that's what I had
 
@brgal This one is more fun to watch:
 {text}←Type words;ratrep;dic;pic;text
 'notes.ratrep'⎕CY'dfns'
 dic←'[a-z]*[aeiouy][a-z]+|[a-z]+[aeiouy][a-z]*'⎕S'\l&'⍠1⊢ratrep
 text←'.',⍨¯1↓∊{⍵,{⍵[?≢⍵]}15↑',,.:###'}¨dic[words?≢dic]
 text←'^.' ',' '([.:])(.)' '#(.)'⎕R'\u&' ', ' '\1 \u2' '.\n\u1'⊢text
 pic←''
 ⎕ED&'pic'
 {pic,←⍵ ⋄ ⎕DL 0.02×2*?4}¨text
Call it like Type 30
 
crazy idea, ever thought about being able to partition the IDE like you can partition a terminal? was thinking that there's a lot of unused vertical space, and it'd be great if I could cut it in half and have two or even three vertical columns
 
@rak1507 So things would overflow move over the top edge of the rightmost column, and onto the bottom of the middle column?
 
3:44 PM
no, not overflowing, just three entirely separate columns, like partitioning a terminal into three columns
 
So they are just parallel sessions to the same workspace?
 
@Adám Great & Fun ! Many Thanks !
 
@Adám yes, without having to open multiple windows
 
That's an interesting idea. It should be possible to create a middle-man layer on the RIDE protocol that connects three RIDEs to a single interpreter.
It might be a problem to identify to which window a particular output is meant to go.
@rak1507 How about one or more input panes, with a single output pane?
 
the thing that caused me to think of that was trying to display lots of various matrices and thinking it would be really nice if I could tile displays horizontally as well as vertically
 
3:52 PM
So you'd want input and its output in each pane?
 
4:04 PM
yeah
 
@rak1507 I know this isn't what you're asking for, but you might still find it fun.
 
that's pretty cool
 
4:18 PM
dumb question: how come ≠¨(1 2 3)(1 2 1) doesn't work?
 
Because bugs.
 
it should do... I think?
oh
 
Of course.
 
known bug, fixing in 18.1?
 
@rak1507 Known, yes. Hasn't been fixed yet. I'll add to the issue that yet another user has hit this.
 
4:22 PM
Alright
@user41805 down to 34
 
4:37 PM
damn, fails for cases with duplicates, that's frustrating
because ≠\0 0 1 0 0 is 0 0 1 1 1
that makes the problem much harder
 
5:00 PM
got a new 34, this problem is very tough I doubt I can go under 30, @user41805 did you have a solution?
 
5:15 PM
@Adám 0,-/¨⌽¨,\⎕
(missed the cmc earlier)
I have a 16 in extended now
 
5:52 PM
@rak1507 Actually, you should be able to Link two separate interpreters to the same directory and get pretty much the effect you wanted.
 
yeah, I can do the effect I want by opening multiple interpreters at once but it'd be nice to do it in one
 
6:14 PM
twitter.com/shaktidb/status/1382396003882573831?s=20 damn this clashes with the dyalog webinar
 
6:39 PM
@rak1507 Can be at least one byte shorter. But I wonder if there's a direct scan for it.
 
6:56 PM
@Adám using the same/similar method?
 
 
3 hours later…
10:06 PM
I so wish scans weren't o(n^2) sometimes, my much longer less elegant solution to a problem is orders of magnitude faster
 
10:18 PM
@user41805 if I post my answer that is currently 34 bytes, and someone helps golf it to under 30, who gets the rep?
 

« first day (1540 days earlier)      last day (1117 days later) »