« first day (1455 days earlier)      last day (1202 days later) » 

12:00 AM
Again, use only what we've learned (there are better ways using additional things we've not learned yet).
 
⋄ IsDivisibleBy←{⍺÷⍵=⌊⍺÷⍵}
 
@diogotito (no output)
 
⋄ IsDivisibleBy←{⍺÷⍵=⌊⍺÷⍵} ⋄15 IsDivisibleBy 5
 
@diogotito DOMAIN ERROR
 
Whoops, almost forgot
⋄ IsDivisibleBy←{(⍺÷⍵)=(⌊⍺÷⍵)} ⋄15 IsDivisibleBy 5
 
12:01 AM
@diogotito 1
 
⋄ IsDivisibleBy←{(⍺÷⍵)=(⌊⍺÷⍵)} ⋄15 IsDivisibleBy 6
 
@diogotito 0
 
⋄ IsDivisibleBy←{(⍺÷⍵)=(⌊⍺÷⍵)} ⋄15 IsDivisibleBy ⍳20
 
That's good. You don't actually need the right hand parenthesis, but it may be helpful for clarity.
 
@diogotito
┌→──────────────────────────────────────┐
│1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0│
└~──────────────────────────────────────┘
 
12:02 AM
@diogotito I love it. That's what I was about to ask you to do next. If you define a function in terms of such mathematical functions (we call them scalar functions) then your function will work that way too.
 
@Adám Is it good practise to always leave parenthesis when possible?
 
@diogotito No, then it'd become unreadable, but it is perfectly alright to have parentheses for clarity or to demonstrate symmetry.
 
⋄ IsDivisibleBy←{(⍺÷⍵)=(⌊⍺÷⍵)} ⋄15 ⍨IsDivisibleBy ⍳20
 
@diogotito VALUE ERROR
 
Oops, wrong location of that operator ⍨
 
12:03 AM
oh!
⋄ IsDivisibleBy←{(⍺÷⍵)=(⌊⍺÷⍵)} ⋄15 IsDivisibleBy⍨ ⍳20
 
@diogotito
┌→──────────────────────────────────────┐
│0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0│
└~──────────────────────────────────────┘
 
I still have to unlearn "high order functions" from functional programming
 
one of the great things about APL is you can write code and it 'just works' so often with any shape of left and right argument
 
@rak1507 … as long as they conform.
@diogotito You can call them that too.
 
I was more thinking scalar + any shape and any shape + scalar
but yeah
 
12:06 AM
@diogotito Can you write IsPrime?
 
Let me try
 
(Note that this will only work for a single number at a time.)
 
⋄ IsDivisibleBy←{(⍺÷⍵)=(⌊⍺÷⍵)} ⋄ IsPrime←{FromTwo ← 1 + ⍳(⍵-2) ⋄ NumDivisors ← +/ ⍺ IsDivisibleBy FromTwo ⋄ NumDivisors > 0} ⋄ IsPrime 13
 
@diogotito VALUE ERROR
 
RGS
@diogotito You tried using in your IsPrime function, but you called IsPrime 13, only with the argument, the one on the right.
 
12:12 AM
Thank you
 
Probably meant
 
⋄ IsDivisibleBy←{(⍺÷⍵)=(⌊⍺÷⍵)} ⋄ IsPrime←{FromTwo ← 1 + ⍳(⍵-2) ⋄ NumDivisors ← +/ ⍵ IsDivisibleBy FromTwo ⋄ NumDivisors > 0} ⋄ IsPrime 13
 
@diogotito 0
 
There's another problem too.
 
⋄ IsDivisibleBy←{(⍺÷⍵)=(⌊⍺÷⍵)} ⋄ IsPrime←{FromTwo ← 1 + ⍳(⍵-2) ⋄ NumDivisors ← +/ ⍵ IsDivisibleBy FromTwo ⋄ NumDivisors = 1} ⋄ IsPrime 13
 
12:13 AM
@diogotito 0
 
⋄ IsDivisibleBy←{(⍺÷⍵)=(⌊⍺÷⍵)} ⋄ IsPrime←{FromTwo ← 1 + ⍳(⍵-2) ⋄ NumDivisors ← +/ ⍵ IsDivisibleBy FromTwo ⋄ NumDivisors = 0} ⋄ IsPrime 13
 
@diogotito 1
 
Nice.
 
Sorry If I rushed a bit there XD
 
No worries.
Instead of adjusting the range to 2…N-1 you could also just test if there are exactly 2 divisors.
 
RGS
12:15 AM
@diogotito @diogotito Cool! I was expecting you to go with ⋄ IsDivisibleBy←{(⍺÷⍵)=(⌊⍺÷⍵)} ⋄ IsPrime←{2=+/ ⍵ IsDivisibleBy ⍳⍵} ⋄ IsPrime¨ 10 13 73 101
 
Yes, that would have been simpler
 
@RGS
┌→──────┐
│0 1 1 1│
└~──────┘
 
RGS
Wasn't ~~ for strikethrough..?
 
No, ---
 
abc
 
12:16 AM
strikethrough
@RGS Ok that makes sense!
 
RGS
@diogotito You can still give it a go, I think. Unless you read my code before Adám's suggestion.
 
I'll try to replicate it without looking
 
Btw, notice how we didn't need commas or parens to form a list? You can actually put any two things next to each other to form a list: ⋄ (1+2)(3+4)
 
@Adám
┌→──┐
│3 7│
└~──┘
 
@Adám what do you think about telling him about some other potentially useful primitives? (⎕UCS 124)
 
RGS
12:18 AM
@rak1507 I like the encoding xD
 
@rak1507 Meh, easy to define in terms of what we've got.
 
True, but still makes things nicer
 
⋄ IsDivisibleBy←{(⍺÷⍵)=(⌊⍺÷⍵)} ⋄ IsPrime←{2 = +/ ⍵ IsDivisibleBy ⍳⍵} ⋄ IsPrime 13
 
@diogotito Can you define Split 7.62 to give 7 0.62? I.e. it splits a number into its integer and fractional parts?
 
@diogotito 1
 
12:20 AM
@Adám Yes!
⋄ Split←{⍵-⌊⍵} ⋄ Split 7.62
 
@diogotito 0.62
 
Oh, I forgot
⋄ Split←{⌊⍵ ⍵-⌊⍵} ⋄ Split 7.62
 
@diogotito
┌→──┐
│0 0│
└~──┘
 
Note that ⍵ ⍵ immediately forms a list.
 
⋄ Split←{(⌊⍵) ⍵-⌊⍵} ⋄ Split 7.62
 
12:21 AM
@diogotito
┌→─────┐
│0 0.62│
└~─────┘
 
And so does (⌊⍵) ⍵
 
Yes
⋄ Split←{(⌊⍵) (⍵-⌊⍵)} ⋄ Split 7.62
 
@diogotito
┌→─────┐
│7 0.62│
└~─────┘
 
Nice.
 
Is there anything shorter than 4 characters?
 
12:23 AM
@rak1507 To implement Split?
 
Yeah
Just wondering really
 
Can you write a function that takes two lists of equal length and computes the fraction of elements in the left argument that are greater than the corresponding element from the right argument?
 
RGS
@diogotito Most (all?) people here like to do code golf, and more often than not, the number of characters of a solution is the only thing that cares to them when solving a problem.
 
Let'me try
 
@RGS Harsh!
 
RGS
12:25 AM
@rak1507 Was it? D: I thought it was pretty accurate XD
 
if you want I can ask him to write a sparse diagonal matrix solver and then I'll care about speed more than code size @RGS
 
RGS
@rak1507 Right :P But that is only for the first implementation. I bet the next iterations of the code will be getting shorter and shorter, and not necessarily faster :P
 
Haha maybe
 
looooool
(I've just realised that pressing backtick with the US layout trigger the JS bookmark and allows me to type the APL characters directly!)
 
@diogotito You should be able to use º on your Portuguese layout too.
 
12:29 AM
You're right! It works!
 
You'll find that the keys are rather mnemonic, e.g. i for and d (round Down) for .
 
and s for round... skyward?
 
XD
 
seiling (c is for cap which cannot be spelled with an s)
 
oops I erased the answer
I'll try to speedrun it now
 
12:31 AM
v for vnion, because APL has to be backwards compatible with mainframe systems written in ancient rome
 
RGS
@rak1507 Can you show me yours? Can only come up with 5 chars.
 
@RGS 0 1∘⊤
 
@rak1507 Looks like 5 to me.
 
(oops)
it's because I didn't actually count it (I can count I promise) but rather misremembered it from the 2018 problem solving competition solutions
in that case ⌊,⊢-⌊ is simpler
 
RGS
@rak1507 I was at ⌊,1∘⊤
 
12:32 AM
If it doesn't bother you too much I'll iterate with the bot
⋄ GtFrac ←{ ⍺÷⍵ } ⋄ 5 5 5 5 GtFrac 1 1 9 9
 
@rak1507 Are you sure you didn't just count from 0?
 
@diogotito
┌→────────────────────────────┐
│5 5 0.5555555556 0.5555555556│
└~────────────────────────────┘
 
@Adám haha maybe
 
@diogotito Sure, or use tryapl.org
 
Thanks!
 
12:34 AM
Avg←{(+⌿⍵)÷≢⍵} the fact this is the given definition of average makes me sad
 
RGS
@rak1507 What would you want to be given?
 
+⌿÷≢
 
RGS
@rak1507 Ah ok :P
 
@rak1507 On TryAPL, you mean?
 
it's so much nicer!
yeah
it's the perfect example of a train, and how nice tacit programming can be
 
12:36 AM
Ok, I came up with
⋄GtFrac ←{ (⍺>⍵)÷(+/⍵÷⍵) } ⋄ 5 5 5 5 GtFrac 1 1 9 9
 
OK, let's find the messages around the time when rak1507 was first introduced to tacit programming…
 
@diogotito
┌→────────────┐
│0.25 0.25 0 0│
└~────────────┘
 
⋄GtFrac ←{ +/ (⍺>⍵)÷(+/⍵÷⍵) } ⋄ 5 5 5 5 GtFrac 1 1 9 9
 
@diogotito 0.5
 
@Adám oh noooo
I think my first introduction to it was bubblers solution to one of the phase 1 problems
which was more complicated than +⌿÷≢
 
12:37 AM
@diogotito Perfect. In fact, you can find the length of a list with monadic (which may render funny if you're using Chrome on Windows).
 
maybe if I'd been introduced to that first (through something like tryapl) I wouldn't have found it so confusing
 
≢ 1 2 3 4 5
⋄ ≢1 2 3 4 5
 
@diogotito 5
 
⋄ ≢⍳420
 
@diogotito 420
 
12:38 AM
@DyalogAPL It'd better be.
 
⋄ {≢⍳⍵} ⍳10
 
@diogotito 1
 
⋄ id ← {≢⍳⍵} ⋄ id ⍳10
 
@diogotito 1
 
⋄ id ← {≢⍳⍵} ⋄ id 1 2 3 4 5
 
12:40 AM
@diogotito 1
 
⍳(1 2 3 4 5)
 
that's certainly an interesting way of doing an identity function
 
OK, I think this is enough teaching for now. Should you want more, then I'd be delighted to continue tomorrow. If you can't sleep, then you can look at apl.wiki/Learning_resources
 
⋄ ⍳⍳5
 
12:41 AM
@rak1507 Not an identity function.
 
@Adám Thank you for your time!!
 
@Adám *for some set of inputs
 
My pleasure.
@rak1507 Any array with a leading axis of length 1…
 
@Adám right yeah I couldn't be bothered trying to think about when it works
 
RGS
Alright @diogotito, how cool is APL? :P
 
12:43 AM
Quite!
 
you mentioned functional programming earlier, do you happen to know any haskell?
 
RGS
Precisely. Are you leaving now/coming back tomorrow for more?
 
Yes, I read some chapters from Learn You a Haskell
 
Do you know what f<*>g is when f and g are functions?
 
ap, If I recall correctly
oh
 
12:44 AM
right
 
It was funny
 
?
 
f <*> g reuses the operand I guess
 
In APL, you can do something similar
you can have (f g h) where f g and h are functions, and if you apply it with one argument you get (f ⍵) g (h ⍵), and with two arguments you get (⍺ f ⍵) g (⍺ h ⍵)
which is why the average can be written as +/÷≢
(+/÷≢) x = (+/ x) ÷ (≢x)
 
Let that sink into my head xD
In your example, f and h are unary functions and g is binary, right?
oh, they can be either unary or binary
 
RGS
12:51 AM
@diogotito But g must be dyadic.
 
yeah, 'monadic' or 'dyadic'
 
@rak1507 Sure, but in my experience, true fgh trains are actually quite rare. Usually either f or h is a constant or identity function.
 
true
well, they're not that rare, but ⊢ f g is probably more common
⋄ ⊢ 1 ⋄ ⊣ 1 ⋄ 1 ⊣ 2 ⋄ 1 ⊢ 2
 
@rak1507
1
1
1
2
 
⊣ and ⊢ are both identity functions monadically, and return what they 'point to' dyadically
 
12:53 AM
@rak1507 Maybe why J's (f g) is (⊣ f g)
 
yeah
 
Oh and because of that combinator stuff code_report always complains about.
 
⋄ palindromic ← ⊢≡⌽ ⋄ palindromic 'racecar'
 
@rak1507 1
 
@Adám I don't think he complains about it, just talks about it
 
12:54 AM
@rak1507 He complains about the APL world having forgotten the connection.
 
Ah right
well fair enough
it's an interesting connection
 
<moon-child> @Adám j also gets away with that because it has caps, so purely monadic applications are easier
 
@rak1507 Oooh! I get it now! +/÷≢is Sum divided by Length!
 
yep!
 
moon-child: I think it is the other way around: J had to add the anomalous cap because (f g) was defined as it was.
 
12:56 AM
Pretty cool!
 
@diogotito It literally reads as +/ sum ÷ divided by length.
 
yeah
⌽≡⊢ 'reverse equals same'
 
@Adám Exactly! I'm still getting overwhelmed by the notation
⋄ ⌽≡⊢ (1 2 3 2 1)
 
@diogotito 1
 
⋄ ⌽≡⊢ 1 2 3 2 1
 
12:58 AM
@diogotito 1
 
Ok, got it!
 
that returns 1 for the wrong reasons
that is doing ⌽(≡(⊢1 2 3 2 1))
 
<moon-child> @Adám fair enough. Causality is sometimes hard to divine :P
 
⋄ ⌽≡⊢ 1 2 3
 
<moon-child> maybe roger knows
@rak1507 1
 
12:59 AM
⋄ (⌽≡⊢) 1 2 3
 
@rak1507 0
 
@rak1507 Erm…
 
yeah, the point was to show that it's wrong like that
 
Oh I see. Thanks!
 
@rak1507 Orthogonal←⍉≡⌹ ⋄ Hermitian←⍉≡+ ⋄ SetDiff←∪~∩ ⋄ Promote←∩,~ Any other using only three primitive functions?
 
1:02 AM
Can't think of many
 
Maybe DirMag←×,|
 
⍉∧⊢ to convert a diagonal matrix to a ... not diagonal matrix? idk if it has a special name
 
> three
 
ah
 
RGS
@Adám IsInt ← ⌈=⌊
 
1:05 AM
@RGS ⊢=⌊
 
there's ⍋⌷¨⊂ for sorting, sort of uses 3
 
RGS
@Adám It computes the same thing, but ⌈=⌊ reads elegantly, that's why I added it.
 
@RGS Double the work, though. -1
 
RGS
Alright, fine, I concede.
 
@rak1507 Nah, here is an identity function.
 
1:07 AM
I suppose
+,-
 
It is just making up for the missing primitive. Also, unless golfing, that definition isn't good, as it is neither general, nor fast.
 
true
 
@rak1507 Yeah, although I kind of feel that , and and {⍺⍵} shouldn't really count, as they don't truly compute anything.
 
fair enough
 
RGS
@Adám How about IsConstant ← ⌊/=⌈/ to see if a list is only composed of a single number?
 
1:11 AM
@RGS ⊢≡∪
 
RGS
Although that's probably not the best way to go about computing that...
@Adám That's not what I mean, I mean it has (possibly) multiple elements, but they are all the same number.
 
Oh, no sorry.
 
1≡∘≢∪ I guess
 
Or ⊃∧.=⊢
 
yeah
∧/∘,∘.=⍨
∘,∘ looks like a face
 
RGS
1:14 AM
Can someone please help me understand when is {f/⍺ g ⍵} different from {⍺ f.g ⍵}?
 
@RGS When any argument isn't a scalar/vector.
 
and g isn't a scalar function, I guess?
 
RGS
@Adám For ranks 2 and above would it be fixed if I had ⌿ instead?
@Bubbler Yeah that makes sense :P
 
@RGS No. I suggest you try it with f←{⍺'f'⍵} ⋄ g←'{⍺'g'⍵}.
 
RGS
@Adám Good suggestion.
 
1:17 AM
Ooh, Range←⌈/-⌊/
 
that's a nice one
 
Oh, so ⌊ and ⌈ live a double life as floor/ min and ceiling/max
 
RGS
@diogotito Yes, they do.
 
Yes. While not directly connected, they both have something to do with going up and going down.
 
RGS
Most of the primitives have different meanings when used monadically or diadically.
For some, their meanings are very very related. E.g. -Y and X-Y, or ÷Y and X÷Y. For others, not so much :P
 
1:23 AM
And for a few, not at all. But they are quite rare, and in those cases, the symbol is quite mnemonic for both.
 
what are some where they're not related at all?
 
RGS
@rak1507 ∊?
 
I guess ≢ and ≡
 
for Enlist and ElementOf
 
yeah
well monadic ∊ could be seen as getting all the elements of the argument
 
1:24 AM
Besides for their traditional dyadic meanings, is very much a tally mark, and is a stack, indicating depth.
 
so they are maybe a little bit related
 
@rak1507 |
 
absolute value is sometimes called the 'modulus', so there must be a connection there
monadic is 0|
that's interesting that 0|¯1 is ¯1
 
RGS
0∘| is a no-op for nums
 
maybe it's more like infinity|⊢
 
RGS
1:28 AM
0∘| doesn't really make much sense mathematically, does it? x∘| is supposed to be the remainder of the argument when divided by x, but you can't really divide by 0.
 
yeah true
 
RGS
Another way to look at it is by looking at the list of possible values, e.g. 3∘| could give 0 1 2, 2∘| could give 0 1 and 1∘| always gives 0, so 0∘| gives... ? :P
 
yeah definitely more like infinity∘|
n|x restricts x to 0 to n-1, |x restricts x to 0-infinity
they seem related to me
 
@rak1507 and
@rak1507 I claimed , but code_report disagreed.
 
typical :P I'll admit I'm not seeing it as obviously as ⌽
oh, I misread what you were saying
yeah, monadic and dyadic ,
 
1:32 AM
@rak1507 Oh right, he found a connection for too.
 
the connection for ⌽ is a little bit dubious but it is nice, the fact rotation can be implemented in terms of reverses
{⌽⌽@(⍺~⍨⍥⍳≢⍵)⌽@(⍳⍺)⊢⍵}
 
The symbol is just so fitting for both.
 
dyadic ⍉ doesn't seem that related to monadic ⍉
 
What are you talking about‽
 
but I never use it for anything other than 0 0⍉x so I wouldn't know
 
1:35 AM
The default left argument of is ⌽⍳≢⍴⍵
 
ah
 
In other words, dyadic reorders the axes to a specified order, while monadic reverses them.
 
@Adám (which should have been 1⌽⍳≢⍴⍵ ... or is it ¯1?)
 
One could argue that 1⌽⍳≢⍴⍵ would have been a better choice of extension from 2D though.
Ninja'd.
But this doesn't detract from their close relationship.
 
I would say monadic and dyadic ⍸ aren't that related
 
1:38 AM
True, that's another odd one.
 
and then there are \/⌿⍀ which are all over the place
 
But monadic is related to monadic and dyadic is related to dyadic , I think
 
True.
 
RGS
@rak1507 BUT those aren't monadic and dyadic per se, just dyadic.
 
@rak1507 Monadic and dyadic f/ are very related.
 
1:40 AM
@RGS as a function, yes, but in general they can either represent reduction or replication, which don't seem all that similar
@Adám agreed
 
RGS
@rak1507 Agreed, I was just being too literal when interpreting the statement that started this discussion.
 
 
7 hours later…
8:45 AM
@Adám were you involved with the dyalog.com/2016-year-game.htm?
 
Wrote an answer for https://codegolf.stackexchange.com/questions/127765/interlaced-rotations : [Try it online!](https://tio.run/##SyzI0U2pTMzJT///v7r0UVeztn71o5690YbaRjWPerfGPuqY8ai3s/zwdEMHjUr9R70rHnWs0D@0QgMop1OhCZLt6Dq0ovJR2wQdIEdPB6gCJKdrqPmobfKj3s0VQBlDbZBRuo86F5VrPupaZHB4enntoRVAyUc9HQZ6poeng2SA6oCKaktBdN/UUOfg/2lgoT6gmx71rnnUu@XQeuNHbROBksFBzkAyxMMz@H86UE01kAOk1NUfdbdo6IAM3qoJotNAjFqudAVjBWOgdnVDI2MTUzNzC0t1oJiZghlCzNHJ2cXVzd3D08vbx9fPPyAwKDgkNCw8IjJK0UFZBaTcUsESpDwkI1WhsDQzOVshqSi/PE8hLb9CIas0t6BYIb8stUihBCidk1hVqZCSn64OAA "APL (Dyalog Unicode) – Try It Online")
 
@JamesHeslip A bit, why?
 
9:05 AM
@Adám were discussing it in Optima, and decided to recreate the problem for this year. (optima-systems.co.uk/programming-challenge-the-year-game) I had a solution for 29 using 2 0 2 1, but I wasn't sure the rules permitted: |20J21
Original rules state 'In addition to the four digits 2 0 1 6, only primitive functions/operators, parentheses/braces, spaces, high minus signs and decimal points can be used. The resultant expressions must be deterministic (that is, give the same result on repeated evaluations).' Does this mean that solution is illegal?
 
Sounds like it.
 
@Adám Dah, will have to find another clever one now... Was pretty proud of myself for spotting that, lol.
 
It is good.
> The original challenge was intended for users of APL, so the official Dyalog rules are specifically tailored to APL solutions, but do not let this put you off trying it in different languages.
I created a spec that works for non-APL solutions:
26
Q: Official Dyalog APL 2016 Year Game

AdámIf you think this could be fun, but too much work, consider participating in this much smaller challenge. A bit of fun (and possibly frustration!) for 2016... Dyalog's "puzzle of the year". Enjoy! The Objective Find Dyalog APL (download) expressions (other languages are allowed, see Eligibility ...

 
<moon-child> @JamesHeslip 20+×⍨2+1
 
Nice!
@JamesHeslip Oh, it even says so in the FAQ:
> Is J (e.g. 37=⌈⍟!20J16) allowed?
> No: In addition to the four digits 2 0 1 6, only only built-in symbols and names, parentheses/braces, spaces, high minus signs and decimal points can be used.
 
9:19 AM
@Adám Ah I missed that, no worries.
 
@JamesHeslip How could you miss it in a text you didn't know about yet?
 
@Adám I thought you were referring to the official FAQ.
 
@Razetime I htink I've got 52.
Golf in progress…
 
9:39 AM
@Adám I knew my algorithmwas too big
it's at 81 right now
 
@Razetime 46.
 
well great
Idk what you've done but you should post it
 
42.
 
⍎⊖⍕⊃⊂|⌊-*+○⌈×÷!⌽⍉⌹~⍴⍋⍒,⍟?⍳0
 
35
 
9:49 AM
what are you doing?~?~??~
 
Removing fluff.
 
huh.
 
@Razetime Meh, feel free to improve your post with this: ⍉⌽m⊣{(b↓e↓m)←⌽⊖b↓m↓⍨e←-b←2⍴⍵}¨⍳≢m←⎕
 
so um
how
 
Just add "-46 thanks to Adám" or something…
 
9:58 AM
lol
 

« first day (1455 days earlier)      last day (1202 days later) »