« first day (1425 days earlier)      last day (1234 days later) » 

6:01 PM
⋄ `(2*⍳ 10)`
lol, I broke something
⋄ `2*⍳ 10`
 
The ⋄ should be inside the backticks, but I wonder why markdown didn't kick in.
 
one properly placed would fix it :p
 
@Konrad 'Unrooted' Klawikowski
┌→──────────────────────────────┐
│2 4 8 16 32 64 128 256 512 1024│
└~──────────────────────────────┘
 
6:02 PM
surely I went too far
 
"X-to-the-power-of-Y"
 
⋄ ⍳ 10 *2
big thonk
⋄ ⍳ 10*2
 
That'd be ⍳100 no?
 
I thought it was space-sensitive
 
It isn't.
 
6:04 PM
thankfully
 
should iota 10 be in parens? like, I want to *2 just the output of iota thing
 
Yes.
 
@Konrad 'Unrooted' Klawikowski
┌→──────────────────────────┐
│1 4 9 16 25 36 49 64 81 100│
└~──────────────────────────┘
 
yeah, seems cool
 
6:05 PM
Bravo.
 
seems pretty logical tbh
 
Can you do the first 10 square roots? 1, √2, √3, √4, … , √10
 
⋄ (⍳ 10)*1/2
 
 @Konrad 'Unrooted' Klawikowski
┌→──────────────────────────┐
│1 4 9 16 25 36 49 64 81 100│
└~──────────────────────────┘
 
⋄ (⍳ 10)*(1/2)
 
6:10 PM
@Konrad 'Unrooted' Klawikowski
┌→──────────────────────────┐
│1 4 9 16 25 36 49 64 81 100│
└~──────────────────────────┘
 
@Konrad'Unrooted'Klawikowski / isn't division.
 
Ah, forgot
⋄ (⍳ 10)*(1÷2)
 
@Konrad 'Unrooted' Klawikowski
┌→───────────────────────────────────────────────────────────────────────────────────────┐
│1 1.414213562 1.732050808 2 2.236067977 2.449489743 2.645751311 2.828427125 3 3.16227766│
└~───────────────────────────────────────────────────────────────────────────────────────┘
 
Can you shorten that?
 
6:11 PM
was there a function to produce a square root?
 
No.
But you do have a reciprocal function.
And remember the order of execution: Generally, you don't need a parenthesis on the right.
 
⋄ (⍳ 10)÷2
 
@Konrad 'Unrooted' Klawikowski
┌→────────────────────────────┐
│0.5 1 1.5 2 2.5 3 3.5 4 4.5 5│
└~────────────────────────────┘
 
Wait not like that
⋄ (⍳ 10)÷
 
@Konrad'Unrooted'Klawikowski SYNTAX ERROR
 
6:20 PM
Wait I don't remember reprodical functions
 
@Konrad'Unrooted'Klawikowski Do you remember division?
 
They were those with two arms on the opposite sides
Yeah, I do
 
And monadic form of divide?
 
Reciprocal
f(x) = 1/x was the reciprocal function, wasnt it?
 
Indeed.
OK, so can use use this in (⍳ 10)*(1÷2) ?
 
6:24 PM
Reciprocal iota 10?
 
No, you want the numbers 1…10 and all of those you want to raise to the power 1÷2
 
Wait, (iota 10)reciprocal was the Syntax error
(iota 10)*(1division2) gives the same as (iota 10)division2
 
@Konrad'Unrooted'Klawikowski No, you're missing * in your expression on the right.
 
⋄ (⍳ 10)2÷
 
@Konrad'Unrooted'Klawikowski SYNTAX ERROR
 
6:32 PM
Aaaa nvm
⋄ (⍳ 10)(1÷2)*
 
@Konrad'Unrooted'Klawikowski SYNTAX ERROR
 
Hold on, think about where APL functions take their arguments.
 
⋄ 2÷(⍳ 10)
 
@Konrad 'Unrooted' Klawikowski
┌→───────────────────────────────────────────────────────────────────────┐
│2 1 0.6666666667 0.5 0.4 0.3333333333 0.2857142857 0.25 0.2222222222 0.2│
└~───────────────────────────────────────────────────────────────────────┘
 
6:36 PM
I have No other idea lol
 
Backtrack: (⍳ 10)*(1÷2) is correct.
 
Oh Yeah it was, tho it needed to be simplified, and I have No idea for that
 
But you're dividing 1 by 2 which is simply the reciprocal of 2.
 
The same but without 1?
 
Yes.
 
6:39 PM
⋄ (⍳ 10)*(÷2)
 
@Konrad 'Unrooted' Klawikowski
┌→───────────────────────────────────────────────────────────────────────────────────────┐
│1 1.414213562 1.732050808 2 2.236067977 2.449489743 2.645751311 2.828427125 3 3.16227766│
└~───────────────────────────────────────────────────────────────────────────────────────┘
 
Yes.
And all this is the right argument of * so you don't need a parenthesis on the right.
 
Hmm
⋄ (⍳ 10)*÷2
 
 @Konrad 'Unrooted' Klawikowski
┌→───────────────────────────────────────────────────────────────────────────────────────┐
│1 1.414213562 1.732050808 2 2.236067977 2.449489743 2.645751311 2.828427125 3 3.16227766│
└~───────────────────────────────────────────────────────────────────────────────────────┘
 
Perfect.
 
6:41 PM
wouldn't (⍳ 10)*0.5 be more intuitive
 
So it gives an approximation of up to 9 numbers after period
 
also this avoids the problem with ÷ capturing more stuff to the right
 
⋄ (⍳ 10)*0.5
 
@Konrad 'Unrooted' Klawikowski
┌→───────────────────────────────────────────────────────────────────────────────────────┐
│1 1.414213562 1.732050808 2 2.236067977 2.449489743 2.645751311 2.828427125 3 3.16227766│
└~───────────────────────────────────────────────────────────────────────────────────────┘
 
It is actually more precise (64-bit float), but by default, it prints 10 significant digits.
 
6:41 PM
Yeah, seems like so Kami
 
⋄ (⍳ 10)*.5
 
@Kamila Szewczyk
┌→───────────────────────────────────────────────────────────────────────────────────────┐
│1 1.414213562 1.732050808 2 2.236067977 2.449489743 2.645751311 2.828427125 3 3.16227766│
└~───────────────────────────────────────────────────────────────────────────────────────┘
 
you can drop the zero too, like in Lua
 
Oh, cool
Haven't seen Lua since I left Awesome WM
 
@KamilaSzewczyk Works for the square root, but not, e.g. for the cube root.
 
6:43 PM
@Adám true that
 
@Konrad'Unrooted'Klawikowski Are you up for more?
 
OK, let's introduce you to the concept of operators.
You're familiar with the ∑ and ∏ notations from TMN (Traditional Mathematical Notation)?
 
I think so I am
 
6:49 PM
the first is for adding and the other one like the same but for multiplying, right?
 
Yes, and it is interesting that you phrase it that way. That means you already see the system.
 
and on the head of that glyph there's a limit to which it should do the action and on the bottom there's an i = something, which means how far the number 'jumps' from one another
 
Why limit ourselves to just + and × and why do we need such unrelated symbols for them. The same operation could be done with any dyadic function!
@Konrad'Unrooted'Klawikowski Yes, and that's usually unnecessary noise, as you already know that you want to process "all the numbers".
So APL has the concept of operators which are a type of higher-order functions. In the simplest form, an operator takes a function as its operand and derives a new related function.
 
E.g. there's the operator / which takes a single dyadic function on its left, and derives the corresponding reduction. We call / reduce:
⋄ +/ 3 1 4
 
6:52 PM
@Adám 8
 
⋄ ×/ 3 1 4
 
@Adám 12
 
is it for making code a more clear one?
 
Is what?
 
those operators
ah, nvm
 
6:55 PM
no
 
It is important to note that while APL doesn't have the normal precedence order with × before + etc. it does have a little bit of precedence: Operators bind any operands they use before any functions are applied.
 
it's like binding foldleft to something in any functional language
 
Yes.
 
6:56 PM
Also note that while a monadic function takes its argument on the right, a monadic (single-operand) operator takes its operand on the left.
There are also dyadic operators, but we'll get to those later.
Also notice that the valence of the operator has no direct connection to the valence of its operand, nor to the valence of its derived function.
In our case, / is a monadic operator, taking a dyadic operand, and deriving a monadic function.
@Konrad'Unrooted'Klawikowski Can you use / to compute the sum of the integers 1…100?
 
@Konrad'Unrooted'Klawikowski 55
 
Yup.
 
⋄ +/ ⍳ 100
sorry forgot that we've moved to 100 now
 
No worries. You get the idea. Let's go back to 10.
How about the sum of the first 10 squares?
 
7:00 PM
⋄ +/ (⍳ 10)*0.5
 
@Konrad'Unrooted'Klawikowski 22.46827819
 
O, that's the sum of the first 10 square roots, but you got it.
 
ah, squares, not square roots, sorry
 
I don't actually need to know the result. It is just to exercise you.
Use APL to compute how many sugar cubes are here:
 
wait
(7*2)+(5*2)+(3*2)+1, but not in APL
 
7:04 PM
That's valid APL.
 
Why not?
 
You're already such an APLer, you use APL without even noticing!
 
⋄ +/ (7*2)+(5*2)+(3*2)+1
 
7:05 PM
@Konrad'Unrooted'Klawikowski 84
 
Yeah, but having both +/ and the interspersed +s is a bit excessive.
It actually ended up having a single number 84 and then summing that, which is still 84.
 
can I write paren with something in it after paren after paren?
 
Not sure what you're intending.
 
I mean, the same but wihout +s?
⋄ +/ (7*2) (5*2) (3*2) 1
 
7:07 PM
@Konrad'Unrooted'Klawikowski 84
 
seems like it worked
 
Oh, yes you can, just like you can write 1 2 3 you can substitute a parenthesis for any element.
But can you write that in terms of the number of layers?
 
ngn
@Razetime what namespace? a js object? ngn/k doesn't (or at least shouldn't) assign to globals other than apl
 
number of layers? wdym? of that pyramind?
 
Yes, there are 4 layers, so we want a formula with 4 (or n) somewhere.
Why don't you work on that, and I'll be back in an hour or so, when my kids are in bed?
 
7:11 PM
sure
⋄ +/ 1 ((1+2)*2) ((1+4)*2) ((1+6)*2)
 
@Konrad'Unrooted'Klawikowski 84
 
gonna play around then
 
ideas on golfing {({⍎4↑∊⍕¨4⍴⍵*2}⍣⍵)1}? rewriting the inner dfn in tacit form doesn't help much (it ends up larger: (⍎4↑(∊(⍕¨4⍴2*⍨⊢))))
 
@KamilaSzewczyk (…)1…⊢1
 
huh
why is it a thing
 
7:25 PM
the tacit form can be golfed to (⍎4↑∘∊(⍕¨4⍴×⍨))
 
it's still one byte longer
 
@KamilaSzewczyk the reason for the parentheses is just that otherwise ⍵ 1 would make an array. We solve that by inserting a (the identity function) in the middle just to syntactically separate the two
@KamilaSzewczyk right, just showing that it can be shortened
 
ngn
@KamilaSzewczyk why both 4↑ and 4⍴? if i'm not mistaken, a single 4⍴ instead of 4↑ should do the same: {⍎4⍴⍕⍵*2}⍣⎕⊢1
 
just arrived at ↑ too
 
hmmmm right
i initially wanted 4⍴ to duplicate the number 4 times
and the made sure we take first 4 digits
but now I noticed it can be simplified
but yeah, you're totally right, 4⍴ still does the same
in tacit form that'd be (⍎4⍴(⍕(×⍨)))
 
7:38 PM
@KamilaSzewczyk (⍎4⍴∘⍕×⍨)
 
aw snap, how did I miss dropping that innermost paren lol
 
8:00 PM
@ngn By the way, remember the answer I was asking for help with yesterday? I got it down to (6∧⌂life⍣(1…4)⍳⊂)(⌽0,⍉)⍣16, so it's a byte shorter, thanks to you.
 
ngn
@user nice :) generally i avoid golfing in "extended". i can't remember all the extensions and there's no point learning them, as it has no practical use.
 
Meh, Razetime's original answer was in it, so I went along with that.
And anyway, golfing doesn't really have much practical use - while concise code is good, I just realized I can't read my own code anymore because I keep golfing it even outside of CGCC :)
 
@ngn n And Vanilla has practical use to you?
 
ngn
@Adám not for me right now, but it does have practical use
also the apl community speaks it, so it can used to communicate at least with them
@Adám i hope it didn't sound offensive
 
@ngn Not at all :-D
@Konrad'Unrooted'Klawikowski Are you here?
 
OK, so the idea with the sugar cube expression as in terms of the number of layers was for you to put all you've learned so far together. Have a go at it!
 
I don't quite get what you've meant by layers, so I was thinking like every layer is 1+2 x n where n is the number of layer under the one with one sugar cube
 
The layers are 1×1, 3×3, 5×5, 7×7.
 
yeah, so the size of width of the layer *2 since it's a square
 
That's right, but not just 1*2, 2*2, 3*2, it it?
 
8:14 PM
yep, since the width size changes +2 every next layer
 
Exactly. So, start off by generating the layer sizes.
 
⋄ (2×⍳ 4)-1
 
@Konrad 'Unrooted' Klawikowski
┌→──────┐
│1 3 5 7│
└~──────┘
 
⋄+/((2×⍳ 4)-1)*2
 
@Konrad'Unrooted'Klawikowski 84
 
8:16 PM
Beautiful!
OK, let's teach you one more monadic operator. This one again takes a single dyadic function as operand, but derives a dyadic function. The newly derived function is equivalent to the old one, except that the order of its arguments are swapped:
⋄ 10 - 3 ⋄ 3 -⍨ 10
 
@Adám
7
7
 
what a weird emoji
describes my mood tho
 
Mine too, a lot of the time.
So while - is "less" or "minus", -⍨ is "subtracted from". We call it commute, because it commutes the arguments.
With that in mind, do you think you can remove all the parentheses from +/((2×⍳ 4)-1)*2 ?
 
⋄+/1 -⍨ (2×⍳ 4)*2
 
@Konrad'Unrooted'Klawikowski 116
 
Nah; a learning experience… Think about what each function sees as its arguments.
 
wait, gimme while
 
Take your time.
 
that 2x part takes iota 4 as a list of arguments
while that iota thing takes 4, which is on their right as an argument
am I right?
 
Yes. (I'd have said "an argument list" instead of "a list of arguments", but yeah.)
 
8:26 PM
⋄+/(1 -⍨ (2×⍳ 4))*2
 
@Konrad'Unrooted'Klawikowski 84
 
now I've just moved it hmmm
 
Ah, but now you have a "trailling parenthesis"; the inner one.
 
hmmmm
⋄+/(1 -⍨ ⍳ 8)*2
 
@Konrad'Unrooted'Klawikowski 140
 
Wait, why "8"? and what happened to the "2×"?
 
just playing around
 
OK, that's fine. APL is very much a language for exploration and trying out things.
 
I can't remove the paren between iota thing and square of that, right?
 
No, but going back +/(1 -⍨ (2×⍳ 4))*2 which worked, what arguments does × see?
 
No. Is × monadic or dyadic?
 
ah, dyadic, it sees both 2 and iota 4?
 
Yes.
 
⋄+/(1 -⍨ (2×⍳ 4))⍣2
 
@Konrad'Unrooted'Klawikowski ·+/···1·3·5·7····2·
 
8:31 PM
Oops, you used instead of *
 
shouldn't it also be a power?
or I didn't get it right
 
It is a power operator, like f²(x) in TMN, which is very different from x².
 
But what would × see if you removed the inner paren?
 
1 -that_weird_emoji 2 and iota 4?
can we call that emojis as [glyph name] umlauts?
tilde umlaut for that mood one for example
 
8:34 PM
No. A dyadic function takes as much as it can "see" to the right only. The left argument is just the adjacent number.
 
so that x would see just iota 4 then...? after removing the parens
 
Sure, call them what you want. The official name for the glyph is tilde diaeresis, but "frown" works too.
@Konrad'Unrooted'Klawikowski No, since it has a number on its left, it's see that as its left argument also.
 
okie
⋄+/(1 -⍨ 2×⍳ 4)*2
 
@Konrad'Unrooted'Klawikowski 84
 
lol it still works?
 
8:36 PM
Nice. Can you remove the last parenthesis in a similar manner?
 
⋄+/1 -⍨ 2×⍳ 4*2
 
And yes, it still works, because of APL's simple precedence rule.
 
@Konrad'Unrooted'Klawikowski 256
 
it would make 4^2?
ah, I see
 
Yes. No, think about what * sees now.
 
8:36 PM
* sees both that thing in parens and 2
I think
 
Yes, and you still want it to see the same expression as left argument, and 2 as right argument.
 
should there be a space or +/ in the beginning would see it as two different arguments?
 
Spaces never matter other than internally in numbers (or strings).
 
⋄+/1 -⍨ 2×⍳ 4 *2
 
@Konrad'Unrooted'Klawikowski 256
 
Think about how you got rid of the parenthesis by swapping the arguments of -.
 
⋄+/ 2*⍨1 -⍨ 2×⍳ 4
 
@Konrad'Unrooted'Klawikowski 84
 
Yay!
Just like a function glyph like - can be ambivalent (stand for both a monadic and a dyadic function), so too can a derived function be ambivalent.
You now know that X f⍨ Y is Y f X but actually, f⍨ Y has a meaning too, namely Y f Y. Take a moment to digest this, as this was the first time I used APL expressions to defined parts of the language.
@Konrad'Unrooted'Klawikowski Digested?
 
8:53 PM
And now you might find easy to remember. It is a selfie! f⍨ is the f-selfie. E.g. Self-addition: ⋄ +⍨ 5
 
@Adám 10
 
And self-multiplication: ×⍨ 5
 
that self-multiplication is like n^n?
 
No, +⍨Y is "double" and ×⍨Y is "square".
*⍨ would be self-power.
 
8:55 PM
Of course, -⍨Y is self-minus, but that'd just give a bunch of zeros.
 
@Konrad'Unrooted'Klawikowski 0
 
Why? That worked as intended, no?
 
yeah it worked
nice thing
 
8:56 PM
OK, do you want to learn how to define your own simple functions?
 
OK, so the simplest form of the simple functions, called "dfns" (pronounced "DEE-funs") are just an expression in curly braces, with (omega, the rightmost letter of the Greek alphabet) representing the right argument, and (alpha, the leftmost letter), optionally, representing the left argument.
⋄ {⍵×⍵} 5
 
@Adám 25
 

« first day (1425 days earlier)      last day (1234 days later) »