« first day (1274 days earlier)      last day (1367 days later) » 

RGS
1:29 AM
@Marshall 10k for BQN?
 
1:57 AM
@RGS "we ask all participants to code and submit their projects on Repl.it"... kind of difficult for a self-hosted language, isn't it?
 
 
2 hours later…
 
3 hours later…
RGS
7:35 AM
@Marshall ugh maybe, it was 2:30 am, my brain wasn't functioning properly
Sorry for that, then
 
8:51 AM
CMC: Construct utility function Shy that can be called from a dfn Caller such that 0 Shy array makes Caller return array like normal, but 1 Shy array makes Caller return array shyly.
 
I thought on how to fix my program I wrote yesterday
I think I may have found a problem with my algo, but I have no idea how to conduct one operation
 
RGS
@Adám is it related to this ⊆⌈ query?
 
@RGS (Cheater!) Yes.
 
RGS
@Adám woops I didn't know it was cheating D: should I delete the msg?
 
Imagine I had a matrix with some values, how do I "select" the smallest value and flip it to one, and leave the rest zeros?
currently I did 0= with the matrix because I assumed there will be an exact result
but it turns out I have to pick the smallest one
 
8:54 AM
No, don't worry. The challenge is pretty trivial anyway, surprising as it may be that this is even possible :-)
 
RGS
@Adám yup, the "surprising this is even possible" part was why I searched aplcart
 
CMC: Construct a utility function Is that can be called from a tradfn Caller such that 'var' Is array makes var a local variable of Caller with the value of array. Is must return array as a shy result.
 
ngn
9:12 AM
@Bubbler that reduction is awkward. have you tried using ¨ or recursion to loop over the right arg?
 
 
1 hour later…
10:16 AM
Is there a smart way to generate a binary mask with 1s for every item on the 'edge' of a matrix (not necessarily square)?
The 3x4 case:
      3 4⍴1 1 1 1 1 0 0 1 1 1 1 1
┌→──────┐
↓1 1 1 1│
│1 0 0 1│
│1 1 1 1│
└~──────┘
 
RGS
@xpqz can't you start with the inner 0s and then just ⍪ the ones all around?
@xpqz frame ← {s ← ⍉1⍪(0⍴⍨⍵-2)⍪1 ⋄ ⍉1⍪s⍪1}
quick and dirty
@RGS frame ← {⍉1⍪1⍪⍨⍉1⍪1⍪⍨0⍴⍨⍵-2}
@RGS frame ← {(⍉1⍪⍨1⍪⊢)⍣2⊢0⍴⍨⍵-2}
 
10:34 AM
:D
That was definitely one of those things that would not be found in APLCart. Surely.
 
ngn
11:29 AM
@xpqz @RGS (⌽∨⊖)0∊¨⍳
 
12:03 PM
That's slick
 
 
1 hour later…
1:05 PM
@Adám I finally did it (lol): codegolf.stackexchange.com/a/207390/61379
but someone else managed to outgolf me and outtime me
 
@Szewczyk Congrats. Btw, please use "APL (Dyalog Unicode)" to avoid future frustration.
 
what's the difference?
 
@Szewczyk only 5 bytes longer than @Bubbler 's offering
 
his algorithm is totally better in every possible way
I picked one that seemed reasonable from a C programmer's perspective (lmao) but also looks quite golfy
 
RGS
1:34 PM
@ngn really nice!
 
2:30 PM
Hello everyone, and welcome to another APL Seeds lesson!
In the last lessons I rushed us through a little APL to reverse Polish "compiler" to try to give a general feel for the kind of thing we are doing here.
And hopefully you can understand why an array-language program to transform one language to another is useful, even the one I presented isn't complete enough to do anything.
I'm going to see if I can do things in a more interactive way this time. I also want to switch from WebAssembly-style instructions, where primitives are immediately executed, to the style used by dzaima/BQN bytecode, which is more general because it allows us to not execute functions, for example to use them as operands.
The idea of this format is that most "instructions" will just be a value to use, and the instruction pushes it onto the execution stack.
We'll also have a few other instructions that apply functions, make trains, create lists, and so on.
As an example, we want to transform the program 1+4÷-2 into 2-¹÷4²+1², where the superscripts denote application with that many arguments.
Here the "executable" version is reversed, but I could also write it ²1+²4÷¹-2 as long as we're dealing with single expressions if you prefer it that way.
Here's our first challenge to warm up: Given a string that contains only monadic functions applied to a single number, convert it to this "executable" form. You can assume functions and arguments are one character long—in the actual compiler I use tokens, which are integers.
Use any array language you like, and any technique you want.
Then we'll talk about why you might want to do it one way or another in a full compiler.
...anyone?
I know people are probably reading these after the fact, but if nobody's here to participate during the lesson then it's much better for me to publish articles instead of trying to do it in chat.
 
2:57 PM
I have returned
and uh sure apl seeds
crickets
 
 
5 hours later…
RGS
7:50 PM
@Marshall I failed to understand how the superscripts are being used... And I also think I didn't understand the challenge. If I only have one value and a sequence of monadic functions, don't I just have to reverse them to get the "executable version" or something of the sorts?
 
@RGS think of the expression 2-¹÷4²+1² as in a stack-based language where 2 pushes 2, - pushes the function -, etc; ¹ pops 2 things off the stack, and calls the last with the item before, and ² pops 3 things, and calls the middle dyadically
(how it looks in dzaima/BQN's bytecode)
(was away during APL seeds unfortunately)
 
RGS
@dzaima (same :/)
@dzaima aaaaaaaaaaah I understand, thanks :)
Now it begs the question, is the first exercise really simple or did I misunderstand it?
 
@RGS it's pretty simple, but being efficient is a bit more complicated
 
ngn
8:13 PM
@dzaima this isn't too different from jvm bytecode. have you thought about targetting it?
 
@Marshall Ok, I'll go first:
s←⊖'abcd2'
(1↑s),(1↓s),¨'¹'
2 d¹  c¹  b¹  a¹
 
Jul 8 at 16:12, by dzaima
i wonder if it'd be feasible to transpile the dzaima/BQN bytecode to Javas bytecode
 
@xpqz Speed demon! You'd have to join these results together because you currently have a nested list, but it's definitely a viable strategy.
The follow up question would be how you can adjust it to work with dyadic functions, or operators, which can need two applications in a row.
 
Sorry couldn't make the Seeds sesh - prime work-zoom-time I'm afraid.
 
@dzaima (the complicated part being about how best to generate the java bytecode and dynamically execute it (the first couple of searches back then made a class file which seemed stupid so i put off the idea))
 
8:24 PM
Would it be better to move APL Seeds later then? We could even try again this week if people are willing to commit to a time.
 
ngn
@dzaima a classfile needn't be a file. it's just a format. you can implement a ClassLoader that generates byte[]-s which the jvm interprets without even touching the filesystem. (this used to be my job a long time ago)
 
@Marshall +1h would normally be safer for me -- but I'm sure we're spread over timezones.
 
@ngn cool, that's more sane. i'll look at it at some point
 
@xpqz Yes, but all the europeans seem to stay up very late.
 
@Marshall i'm fine with any day any time around T-12h to T+5h; today (& yesterday) were exceptions, i'll probably be constantly around for the next month
 
ngn
8:33 PM
@dzaima i recommend reading the jvm spec. it's unusually well written for something in the java ecosystem (guy steele was involved in the early editions!). the bcel library used to be the most popular way to generate bytecode, but things might have changed in the last decades. (unfortunately bcel wasn't available when i started, it appeared later, so i'm not very familiar with it)
 
@ngn i'd definitely reference the spec, but most of my problem was more the API side of things. Surprised seeing you recommend a library :p
 
ngn
@dzaima well, as i said, i'm not very familiar with it, i recommend it only because it was popular
 
@ngn still; i was pretty much ready to manually write bytes if i had something to feed them into to get executed :p
 
ngn
btw, to inspect the bytecode of a class: javap -c pkg.pkg.pkg.ClassName (this has always been in the jdk but surprisingly few people know it)
@dzaima just look at ClassLoader's javadoc. i think it was an abstract method or something.. you're supposed to return the byte[] and the jvm knows what to do with it.
 
@ngn that's what it looks like. anyways, have to do something else currently
 
8:43 PM
Anyway. Past my APL bedtime. o/
 
8:58 PM
Here's some stuff on usage of leading axes in BQN. I probably need to split some of the sections into separate pages.
 

« first day (1274 days earlier)      last day (1367 days later) »