« first day (266 days earlier)      last day (2388 days later) » 
05:00 - 18:0018:00 - 22:00

6:00 PM
@EriktheOutgolfer Yeah, like 3 4⍴'abc'
 
oh you mean the right argument
 
that's also how jelly's (mold) works, except that in jelly you use a list with the intended shape, not a list of dimensions
 
@EriktheOutgolfer Yeah, Jelly doesn't have rank.
 
it does have a "depth" function (ŒḊ) but it's not really the same
 
6:02 PM
Ok, can we move on from dimensions, we're stuck here for about 15 minutes...
 
APL, J, Matlab, and Mathematica have both, if I understand correctly.
 
like, mold and reshape?
 
Well there is no built-in Mathematica does not have anyway
 
@EriktheOutgolfer depth and rank, I think
 
@EriktheOutgolfer ^
 
6:03 PM
@Adám maybe something like python's """ multiline strings? like [[[1 2 3\n4 5 6\n7 8 9]]]
 
@Uriel That's very limited. You can't go 7D with that.
So, let's have a look at some of the built-ins (primitives in APL lingo) that deal with rank and depth and shape.
 
@Adám I wouldn't expect someone to type 7D arrays in his code, but matrices should be legit
 
Most primitive APL functions have both a monadic (one argument) and a dyadic (two arguments) form. It is always clear from context which one is being applied, as all monadic functions are prefix, and all dyadic ones are infix.
So, we already addressed the dyadic which was "reshape". The monadic is "shape". So it reports back what the shape is.
 
s/alway/always/
 
CMC: What is the shape of a scalar, like 42?
 
6:06 PM
[]
 
@EriktheOutgolfer Right.
 
(note: gotta learn how to do empty array in apl)
 
@EriktheOutgolfer ⍬
 
then
 
So if you have a vector like 1 2 3 and want to "fill" a simple scalar with that data, you can do (0⍴0)⍴1 2 3
And yes, is a shortcut for 0⍴0.
So ⍬⍴1 2 3
Gives 1 of course.
 
6:08 PM
@Adám I'd consider it more like the opposite
 
@EriktheOutgolfer Why?
 
0⍴0 would return
 
is the operator though
 
@EriktheOutgolfer No they both return an empty list. It is just a way to write it.
 
Why does f←{⍴⍵}⋄ f5 Raise a VALUE ERROR?
 
6:09 PM
@J.Salle No, is not an operator.
@Mr.Xcoder Because names may have multiple chars, so you need a space to distinguish f 5 from f5
 
@Adám it's not? Is it like a quick in Jelly then?
 
@Adám it's a function right?
 
@J.Salle No, it is a constant. Like 5
 
Oh okay
 
@J.Salle not quick, nilad
 
6:10 PM
@Adám APL does not output [] does it? It outputs an empty string instead right?
(or nothing, actually)
 
@Mr.Xcoder By default yes. But you can tell APL do to give you more info than that.
 
I guess my code was correct since f←{⍴⍵}⋄f 2 3 5 gives 3.
 
Also, you can convert nested lists (no high-rank arrays) to JSON.: Try it online!
 
that's a string right?
 
@EriktheOutgolfer Yes, the result of ⎕JSON is a simple character vector..
Back to primitive functions.
We mentioned monadic which ups the rank (at the cost of one level of depth).
We can also lower the rank with and thereby gain a level of depth.
 
6:15 PM
what is the builtin to return the rank of an array?
 
@EriktheOutgolfer There is none, because if you think about it, the rank is the shape (well actually the tally) of the shape.
So is shape. ⍴⍴ is rank. ⍴⍴⍴ is 1.
 
However, there is a primitive for depth: (you see the layers, right?)
@EriktheOutgolfer Yes.
And the rank really should be scalar. The result of is always a vector.
So there is a different primitive for count (called Tally): it looks like a tallying mark.
 
so...what is the difference between rank and depth?
 
Depth is the level of nesting. Rank is the number of dimension.
 
6:20 PM
for example [[[1]]] has depth 3 and rank 3 right?
 
It may seem unnecessary now, but it comes in really handy.
@EriktheOutgolfer No, rank 1. It is a vector.
 
Matrices have rank 2, "cubes" have rank 3, etc.?
 
@EriktheOutgolfer There simply isn't any JSON notation for higher rank.
 
@Adám so what is rank 2, 3, etc.?
 
@EriktheOutgolfer As @J.Salle said.
Blocks are rank 3D. Hyper-blocks (if you want) are rank 4.
 
6:21 PM
so how do we represent a "matrix" or a "cube" in apl, if it's different from just (1 2 3)(4 5 6)...
 
@EriktheOutgolfer You can either use to reshape the data, or use to exchange depth for rank.
 
so rank is actually something internal?
 
(2 3⍴1 2 3 4 5 6) is the same as ↑(1 2 3)(4 5 6)
@EriktheOutgolfer Yes, internally, arrays are stored as rank, shape, data
 
what is ↑ called?
 
Ups?
 
6:24 PM
@JohnDvorak "Mix", because it mixes elements together to form higher rank arrays. As opposed to "Split", , which splits high-rank arrays into lists of lesser-rank arrays.
 
Oh makes sense
 
json kinda fail right
 
Btw, if you use Chrome on Windows or macOS, may render kind of like ≡/ which is a bug. You may add your voice here.
 
luckily I'm on ubuntu
 
They do render exactly the same (for my near-sighted eyes at least)
 
6:27 PM
@EriktheOutgolfer Yes, ⎕JSON will refuse to convert things that cannot be represented in JSON.
 
Yes, they render correctly for me too (macOS)
 
but you're using safari
 
@Adám this is why I no longer use Chrome
 
@J.Salle is supposed to look like but with an additional underscore like
 
Yeah I've seen it on tryapl
 
6:28 PM
I think it's really windows's and mac's fault, since rn I'm using chrome on ubuntu and those two render differently for me
 
not because of ≢, but because the way bug reports get handled in general.
 
@EriktheOutgolfer I suspect it is Blink's fault because they render correctly in all other applications on Windows and macOS.
 
blink's?
 
new name for Webkit
 
@EriktheOutgolfer Chromium's rendering engine.
So now we have monadic ↑ ↓ ≡ ≢ ⍴ and dyadic .
 
6:31 PM
because they wanted the webkit- css prefixes to no longer work :P
 
@Adám forgot monadic in there :p
you specified it above
 
@EriktheOutgolfer it's there
 
Monadic always returns a vector. Monadic always returns a scalar. on a matrix returns the number of rows. on a 3D block returns the number of layers, etc.
 
So it's always the number of the 'highest rank' of sorts?
 
6:33 PM
in short: is length
 
@Everybody has an ok understanding of APL arrays?
@J.Salle Yes.
 
Ok good.
 
also yes
 
@EriktheOutgolfer Not really, because "length" is not a well defined term for high-rank arrays.
We prefer to call it the tally of "major cells".
The concept of major cells is important when it comes to manipulating and comparing arrays, but we can address that when it comes up.
Let's manipulate some arrays!
 
6:35 PM
Let's do it \o/
 
@Adám I think I do.
@Adám Sure yay
 
We already saw how dyadic can reshape things. Dyadic is take. In order to speak about its two arguments easier, we will give them names. The left argument we will call as in the leftmost letter of the Greek alphabet, and the right argument we will call as in the rightmost letter.
So ↑⍵ is monadic and ⍺↑⍵ is dyadic..
⍺↑⍵ takes the first major cells (!) from . E.g. 3↑3 1 4 1 5 is 3 1 4.
CMC: Any guesses (those that don't know) as to how we take from the back instead?
 
negative ?
 
@EriktheOutgolfer Yes!
 
6:39 PM
3 1 4 1 5 ↑ 3 ?
 
@JohnDvorak No.
 
aww :-)
 
That would make it impossible to know what 3↑4 means.
If you take more than there is, APL will pad with a fill element.
 
¯3↑3 1 4 1 5 = 4 1 5 ?
 
@J.Salle Yes.
 
6:40 PM
Nice
 
I guess you won't accept disallowing scalar ↑ scalar? :-)
 
@JohnDvorak Of course not. All arrays are created equal, and anyway vector ↑ ⍵ is meaningful.
CMC: And any guesses as to how we drop elements?
 
the down arrow?
 
Correct. And you can remove from the back with negative , of course.
 
6:42 PM
@Adám How is the filler element determined?
 
@Laikoni Excellent question.
APL arrays have something called prototype. The prototype for numbers is 0 and the prototype for chars is a space. This is really handy in codegolf!
 
and the prototype for mixed?
 
@EriktheOutgolfer The first element's prototype.
 
I guess that's quite handy too
 
6:44 PM
For an array of arrays, the prototype is the first element, but with all numbers made 0 and all chars made spaces.
 
E.g. the prototype of (1'a'2)(3 4) is 0' '0
 
@Adám you mean with all elements prototyped right?
that is, the prototype of ((1 2'a')3)(1 2 3) is ((0 0' ')0)
 
@EriktheOutgolfer Yes. the 1 and 2 became zeros, and the a became a space.
@EriktheOutgolfer correct.
 
Are functions first-class citizens in APL?
(If so, what is their prototype?)
 
6:47 PM
I guess they are refs
 
@Laikoni I could go there, but I think it belongs in a different lesson, as we are doing data here.
 
I just posted an challenge on Main. What if we try to solve it together now?
 
1
Q: Am I a golfy array?

Mr. XcoderDefinition and Rules A golfy array is an array of integers, where each element is higher than or equal to the arithmetic mean of all the previous elements. Your task is to determine whether an array of positive integers given as input is golfy or not. You do not need to handle the empty list. ...

 
@Mr.Xcoder I just saw that, sounds like good exercise
 
@Adám hah ninja
 
6:49 PM
For example, does APL have built-ins for arithmetic mean and prefixes?
 
btw it would help if there's an average builtin
 
Give me a min to read it.
 
Sure.
 
in J the average is a train, plus-over divided by count
 
@JohnDvorak Exactly the same in APL, but with nicer glyphs.
 
6:51 PM
but harder to type
 
@JohnDvorak Not if you have an APL keyboard layout.
 
(+/÷≢) I guess?
 
@EriktheOutgolfer Correct.
Although it gives 1 for the empty list.
 
Wait wut
 
Because 0÷0 is 1 in APL by default (you can change this though).
 
6:53 PM
except that the average of an empty list isn't defined at all :p
 
@EriktheOutgolfer No, but it would be handy to say it is 0 for that challenge.
 
Uriel just posted an answer in APl.
 
But +/÷1⌈≢ works.
 
but it's not a train anymore is it
 
@Mr.Xcoder Yes, and it uses APL features that may be a bit too advanced for the participants here.
 
6:54 PM
@Adám (kinda unrelated, but anyways) can I install dyalog apl on my windows and my linux distro using the same non-commercial serial number?
 
@EriktheOutgolfer Yes it is. Any sequence of functions with no data on the right is a train.
 
@Adám Ok.
 
@Adám so that is a 4-function train I guess
 
@J.Salle If you want Dyalog APL for 2 OSs, then apply for two licences. I actually don't know if Karen will give you two serial numbers, but it doesn't matter what you enter into the serial number field upon install :-)
 
@Adám Note that for the purpose of this challenge, we will assume that the average of an empty list ([]) is 0.
 
6:56 PM
@Adám okay, sounds good!
 
@EriktheOutgolfer It is a 5 "car" train. One "car" is not a function, but it is still a train because there is no data on the right.
I think we should continue with a few more array-manipulation primitives before we try tackling Uriel's solution.
The remaining array manipulation primitives are really simple. Monadic enlists an array. It takes all the data, on all levels of depth and rank and creates a simple vector of depth 1.
 
Wait so (+/÷≢) is arithmetic mean? I didn't really pay attention for the last few minutes.
 
@Mr.Xcoder yes
 
@Mr.Xcoder Yeah. Because +/ is sum. But we have not addressed / yes.
 
@Adám Is the dyadic counter part the element function?
 
6:59 PM
And is length right?
 
@Mr.Xcoder Yes.
@Laikoni Dyadic counter? or or something else?
We already mentioned monadic , which ravels high-rank (or low rank) arrays. It creates a vector of all elements, but it does not flatten depth.
 
@Adám I meant "counterpart"
 
@Adám Can you link me to that page with what each function does again please? Thanks.
 
@Laikoni I still don't understand.
 
Whether 1 ∊ 1 2 3 yields some truthy value because 1 is an element of 1 2 3.
 
7:02 PM
he probably means dyadic
 
@Mr.Xcoder I use tryapl.org, the primer section
 
@J.Salle I know about that one
 
@Laikoni Yes, it is membership, like in normal math.
 
except that tryapl has an older version
 
@Mr.Xcoder All primitives
 
7:03 PM
Yes thanks.
 
@Mr.Xcoder Oo sorry, didn't see you were going over it
 
@Uriel Nah, we wouldn't have solved it anyway
 
@Uriel No problem.
 
@EriktheOutgolfer Exactly. Is there some language issue with "counterpart"? It sounded natural to me.
 
@Laikoni Not at all, I just didn't realise what you meant with "element".
Dyadic , is concatenation.
So 1 2 3,4 5 6 is 1 2 3 4 5 6.
 
7:06 PM
@Adám it then follows that ; is pair right?
 
It works for any-rank arrays, but they have to conform. You can even concatenate a vector to a matrix, and that will concatenate one element from the vector to each row of the matrix.
@EriktheOutgolfer pair? (and no, ; is special syntax in APL, not a function)
 
@Adám Oh, I used "element" because of Haskell's elem. In hindsight "member" is the more common term.
 
oh so it vectorizes
 
@EriktheOutgolfer Yes. And if you try concatenating a scalar to a matrix, it will expand the scalar to concatenate it to each row too.
 
7:08 PM
Yeah APL has auto vectorization
 
@Uriel Wow 16 bytes is rather impressive given that the Jelly solution is 5 bytes.
 
@EriktheOutgolfer Now, as you can see, , concatenates horizontally. You can't concatenate two elements to three rows (Check the debug pane of TIO!)
 
I'd expect it to "recycle" though, wouldn't it be more reasonable given how others recycle too?
 
7:11 PM
@EriktheOutgolfer Maybe. But only recycles.
 
@Mr.Xcoder looking at the jelly explanation, they are practically the same
 
If you want to concatenate vertically, then you use (comma-bar).
 
oh that's what means?
I thought it meant rank
 
@EriktheOutgolfer No, rank is ≢⍴ (the tally of the shape, i.e. how many dimensions)
 
@Adám Btw, why is the code in the input field on TIO? Is there a distinction between snippets and full programs and only the later work in the code field?
 
7:12 PM
...
 
CMC: Get the Nth Fibonacci number. If it's a built-in, you may not use it.
 
wrong room
 
@Laikoni The main reason for using Input now is that expressions in INput have implicit output. Expressions in Code would require me to include the printing code.
 
@JohnDvorak Nope.
 
@Mr.Xcoder We can do that, but we have not gone over enough yet.
 
7:14 PM
@JohnDvorak he meant "don't copy from dfns cheaters!"
also ^^
 
Also, factorial is probably a better starting function.
 
@Adám Really? Isn't my knowledge about functions from yesterday enough to solve it?
 
(not the built-in !, cheaters!)
@Mr.Xcoder Oh, yes, you should be able to, but not the others.
 
(ok, I'll try it myself) - BTW can my factorial function from yesterday be shortened?
 
@Mr.Xcoder Yes, but not if you want to keep it recursive.
 
7:16 PM
I want to keep it recursive.
 
Factorial is just the product of the range: ×/⍳
 
@Adám I did it yesterday though hahahah
 
@Adám IIRC, there was a - 1 built-in?
 
yup 5 bytes (×/⍳)
 
I'll withhold my answer until @Mr.Xcoder comes up with one though
 
7:17 PM
@EriktheOutgolfer 3, you don't need parens.
 
Yes, but I wanted to do it recursively.
@J.Salle You can reveal the byte count though.
 
3 mins ago, by Adám
(not the built-in !, cheaters!)
 
Damn, I would have used shape-infixes (n shape 0)
 
@Adám huh
 
@Mr.Xcoder 15 chars, 24 bytes according to TIO
 
7:18 PM
@Adám Huh? I want a decrement built-in!
Is there any?
 
@Mr.Xcoder Only a generalised one that lets you specify how much you want to decrement with.
 
ok...
 
-
 
I know lol...
 
huh... when would you use that?
 
7:20 PM
@JohnDvorak He could decrement recursively until the factorial is 1.
Just a few more structural manipulation primitives and we are done.
Monadic is like monadic , but returns all the data raveled into a matrix instead of a vector. Each major cell becomes a row.
is reverse when used monadically. It mirrors over the indicated axis |
 
padded to the largest cell?
 
@JohnDvorak No, high-rank arrays always have conforming cells. does not penetrate nesting.
 
@J.Salle I have 19 characters. BTW do the { and }count?
 
@Mr.Xcoder I didn't count ← and the {}
 
I still don't know what a wrap drive is
 
7:23 PM
@J.Salle I don't have any :-)
 
flips matrices upside-down. In general is reverses the order of the major cells.
 
So I have 17 characters.
@J.Salle Is my solution similar to yours?
 
@Mr.Xcoder He means that he doesn't count the assignment to a name.
is of course transpose :-)
 
@Mr.Xcoder Here's mine
 
@Adám yes I know. But anyway it is irrelevant for my case.
What is / and what is ¨
?
¨ is each.
 
7:25 PM
@Mr.Xcoder +/ is sum, ¨ is each
 
@Mr.Xcoder / is reduction (like +/ is sum) and ¨ applies a function to each element of an array.
 
Nice. I was quite close anyway :-)
 
Neither are functions, btw.
 
Indeed
 
I am afraid I have to go. See you all o/
 
7:26 PM
@Mr.Xcoder 'tis been grand. Thank you for causing this lesson to happen at all.
@Everbody else wants to continue or should we call it a day?
 
let's call it a day I guess
btw thanks for the lesson @Adám
 
OK. Anyone interested in continuing this next week?
 
@Adám Thanks a lot for teaching us! Very nice lesson.
@Adám I am interested in continuing the learning process, yeah.
 
@Adám sure
 
I think I'll hop in
 
7:29 PM
@J.Salle ooh that's a smart method. I golfed it to 14 bytes though
 
in the meanwhile, let's practice on what we learned today for this week I guess
 
@dzaima nice! Link?
 
OK, I'll announce in TNB before. Thank you all for attending, and of course, feel free to hang around and ask questions.
 
@EriktheOutgolfer I concur.
Bye!
 
7:30 PM
I'm usually here all UK day, Monday-Thursday.
 
@Adám and yeah, for sure! Thanks a lot
 
@J.Salle It's a pretty insignificant change - 1 2 -> ⍳2
 
@dzaima 50% reduction in byte count.
 
@dzaima golfing is never insignificant! hahahahahah
 
@J.Salle Well, compared to your idea of using ∇¨ it's way simpler (in terms of easiness not golfiness)
 
7:37 PM
Adám has added an event to this room's schedule.
 
7:49 PM
I feel like there should be a shorter fibonacci possible but can't think of a way of doing it..
 
@dzaima This one is cute: (⊢,(+/¯2∘↑))⍣10⊢1
 
@Adám oh wow that is smart. I was thinking about using and having the last numbers stored up but didn't think of storing them all and using
 
8:21 PM
@Adam I think this pattern would make a nice challenge to demonstrate APL
4 ->
0  1  2 3
¯1  0  1 2
¯2 ¯1  0 1
¯3 ¯2 ¯1 0
darn formatting
 
@Uriel 8 bytes
 
@dzaima this is one of 2 obvious solutions
note the word "obvious"
 
@Uriel the other is less golfy, right?
 
@dzaima same length
 
@Uriel huh
 
8:32 PM
but I didn't say they both are the golfiest
 
9:24 PM
@dzaima Brian (my manager) came up with: {⊃{⍵,+/¯2↑⍵}/⌽⍳⍵}
 
Jun 7 at 12:47, by Uriel
@KritixiLithos I believe it's {1∧+∘÷/0,⍵/1}
 
@Uriel That is very clever. You don't really need the 0, though, and you can get all the terms by swapping \ for /: {1∧+∘÷\⍵/1}
 
@Adám as I said, not mine. though the 0 starts the sequence from 0, 1 rather than 1, 2
 
05:00 - 18:0018:00 - 22:00

« first day (266 days earlier)      last day (2388 days later) »