WEBVTT
00:00:12.320 --> 00:00:16.320
Welcome to ArrayCast episode 125.
00:00:16.719 --> 00:00:23.359
I am your host, Connor, and I'm here today with the only panelist, therefore co-host for the time being.
00:00:23.600 --> 00:00:33.600
Adam, I guess we'll go around just for old time's sakes and do brief introductions, and then we've got two announcements, and we've got hopefully a fun topic, maybe a little bit different because we've got this YouTube format.
00:00:33.679 --> 00:00:36.880
But before we get to that, uh we'll do a brief introduction from Adam.
00:00:37.280 --> 00:00:38.799
Right, I'm Adam Botsewski.
00:00:39.119 --> 00:00:41.359
Um I've been doing APL my whole life.
00:00:41.520 --> 00:00:48.880
I I do APL at Dialog Limited, where we create the APL of the future, I could say.
00:00:48.960 --> 00:00:57.359
And I'm I've been honored to become the head of language design there, but I also deal with everything else dealing with the language at dialogue.
00:00:57.679 --> 00:01:02.960
And as always, I am your host, Connor, massive fan of all the array languages.
00:01:03.280 --> 00:01:07.680
And yes, we have two announcements I day, uh I believe today, both from Adam.
00:01:07.760 --> 00:01:10.719
So I'll throw it over to you and then we'll hop into our conversation.
00:01:12.079 --> 00:01:30.400
Um right, so I unfortunately had to announce in the last episode that uh Kitty Christensen, the former CEO and uh um of Dialic Limited, and much of the reason that we've been here today, uh passed away, uh, there was a uh a funeral service for her.
00:01:30.640 --> 00:01:42.480
And there's also been set up a uh a memorial site where you can both uh see a lot about her and uh bituary and and other things, but you can also add your own tribute.
00:01:42.640 --> 00:01:44.239
I'm sure that a lot of people want to do that.
00:01:44.640 --> 00:01:46.799
So it's gittercrestens.
00:01:48.799 --> 00:01:51.120
And we'll leave a link to that as well.
00:01:51.840 --> 00:02:16.479
And then uh there is the APL Forge, which is uh the thing we do a dialogue every once a year, um where we let people submit um projects that you started in or for dialogue APL, and it comes to an end once a year, and then we start a new round, and there's one month left of this year until we stop at the round and there's the next round.
00:02:16.560 --> 00:02:30.879
And you can still if you have some kind of cool thing you made in APL, um then you can uh still um submit it and then we'll have a look at it, and you might win a price and um a trip to the next user meeting.
00:02:31.120 --> 00:02:33.759
So have a look at uh forge.dialog.com.
00:02:34.000 --> 00:02:37.439
And we will have links for everything that just got mentioned in the show notes.
00:02:37.599 --> 00:02:43.199
And surprise, surprise, we have now a second panelist, or technically guest.
00:02:43.280 --> 00:02:48.639
I mean, you are listed on raycast.com as a recurring panelist, so I guess you are a panelist for today.
00:02:49.120 --> 00:02:49.680
How's it going?
00:02:50.879 --> 00:02:52.800
It's not bad, it's not bad, kind of thanks.
00:02:52.960 --> 00:02:57.599
You're popping into a live stream on YouTube, so I'm not sure if you've heard, but things are things are different now.
00:02:57.680 --> 00:03:00.080
You know, there was the before era, now there's the after era.
00:03:00.319 --> 00:03:04.639
And in this after era, uh we just uh You just go straight there.
00:03:04.879 --> 00:03:18.319
Yeah, it's mostly laziness, I guess, because Bob was doing a lot of work back in the before era in a raycast 1.0, and Adam and I wanted to keep on keeping on, but I did not have the time to uh put the amount of effort that Bob put in.
00:03:18.400 --> 00:03:20.479
So we said, What uh I thought to myself, what's the easiest way?
00:03:20.560 --> 00:03:29.919
And I was like, wait, in Tacitalk, I just live stream, I do a little bit of post-processing, and if AI gets good enough, maybe it'll actually it'll never reach Bob levels.
00:03:30.080 --> 00:03:34.479
But you know, maybe the ums will get removed and the the dead air will get removed.
00:03:34.719 --> 00:03:37.680
And uh, anyways, um it's good to have you here.
00:03:37.840 --> 00:03:40.319
And in the chat, we've got uh multiple hellos.
00:03:40.560 --> 00:03:45.039
Well, one person saying hello to the chat, but also Max, aka meme god, saying, Wow, it's rich.
00:03:45.120 --> 00:03:48.560
You know, he's uh Is that Max?
00:03:48.719 --> 00:03:49.280
Sorry?
00:03:50.000 --> 00:03:53.599
I saw him not long ago, so yeah in in real life.
00:03:53.680 --> 00:03:54.719
So hello again.
00:03:54.960 --> 00:03:56.400
I also saw him not long ago.
00:03:56.479 --> 00:04:00.800
I mean, he's local to Toronto, so I guess it's probably easier for me to see him than it is for Right.
00:04:00.879 --> 00:04:02.639
I had to fly a long way.
00:04:03.919 --> 00:04:08.479
All right, well, you joined just in time uh for a little bit of a different episode.
00:04:08.560 --> 00:04:11.439
So Rich, I guess, has no idea what's about to happen.
00:04:11.680 --> 00:04:22.160
And um, Adam got, I believe, if you include the time when he was reading the announcements and introducing himself, a grand total of like 10 minutes to ruminate about this problem.
00:04:22.240 --> 00:04:29.120
But we're gonna uh chat about a toy trivial uh problem from Pearl Weekly Challenge.
00:04:29.199 --> 00:04:30.720
We actually don't know the number.
00:04:30.959 --> 00:04:39.439
If for whatever reason this gets back to the Pearl Weekly Challenge people, uh you clearly vibe coded, which I've got nothing, I'm I'm a big vibe coder.
00:04:39.519 --> 00:04:47.279
Uh I love vibe coding, but they vibe coded an upgrade to their Pearl Weekly Challenge website, and it is no longer clear to me.
00:04:47.439 --> 00:04:50.560
I mean, I spent like three minutes, that's why we were a bit late starting this episode.
00:04:50.639 --> 00:04:55.680
I mean, the podcast people and the audio players have no idea that we were three minutes late, but the folks on YouTube know.
00:04:55.759 --> 00:04:59.759
And we couldn't find the the past uh problem links.
00:05:00.000 --> 00:05:07.279
Anyways, I happen to recall the problem from memory, so this was in the last like month or two though, and I never actually solved this problem.
00:05:07.680 --> 00:05:13.040
I read it, I thought about it, and then I couldn't find an or think of an elegant way to solve this.
00:05:13.199 --> 00:05:21.839
It's definitely solvable quite easily, but like I couldn't think of a kind of single one-liner tacit solution because there's a kind of a couple edge cases.
00:05:22.000 --> 00:05:22.800
So here's the problem.
00:05:22.879 --> 00:05:28.720
And I'm not sure if at some point uh I want to share my screen or screen or Adam wants to share his or Rich, you can even share yours.
00:05:28.959 --> 00:05:32.319
I'm on the table of problems now on the on the weekly challenge site.
00:05:32.399 --> 00:05:33.839
So once you describe it, I think.
00:05:34.160 --> 00:05:39.680
Does it is it the one that says recap, or is there like a link to because the recap one just No no slash challenges?
00:05:39.839 --> 00:05:43.839
So it funnily enough, in the title bar, it's under the tab this week.
00:05:44.000 --> 00:05:46.560
So that's the one I went to.
00:05:46.720 --> 00:05:47.600
That's the one I went to.
00:05:47.839 --> 00:05:50.800
And then I would think, oh, it's just for this week, it's actually past weeks.
00:05:50.959 --> 00:05:53.680
But when you click on recap, it doesn't bring you to the problem statement.
00:05:53.759 --> 00:05:55.759
It just shows you how many languages it was solved in.
00:05:56.000 --> 00:05:56.560
Oh, I see.
00:05:56.720 --> 00:05:57.759
No, no, I'm not that far.
00:05:57.839 --> 00:05:59.120
I'm just at the table of Yeah.
00:05:59.360 --> 00:06:04.319
Look at that though, like the UI experience here, two different people completely unrelated, did the exact same thing.
00:06:04.399 --> 00:06:08.319
They they found the challenges under this week, thought that's a weird place to put it.
00:06:08.480 --> 00:06:13.040
And then it turns out uh, first of all, it's not for this week, it's for the past weeks, but it doesn't actually show the problem description.
00:06:13.439 --> 00:06:16.319
It's an abbreviation for this and all weeks.
00:06:16.720 --> 00:06:18.240
Yeah, obviously.
00:06:18.480 --> 00:06:20.000
Uh go on, describe the problem.
00:06:20.079 --> 00:06:20.560
We'll we'll see.
00:06:20.879 --> 00:06:41.439
So the problem is, and it may be someone in the YouTube chat, because we've got a few viewers, um, and and play along as well if you're on YouTube doing this live, and also if you're listening to this in Spotify, Apple Podcasts, whatever player you use, you're given a string of lowercase characters, and you want to return the largest distance between two equal characters.
00:06:41.600 --> 00:06:43.439
So two characters that are the same.
00:06:43.680 --> 00:06:52.480
And if there are no duplicate characters, so there's no two characters to find a large distance between, uh, it is you return negative one.
00:06:52.800 --> 00:06:55.600
And you it's exclusive of those two characters.
00:06:55.680 --> 00:07:07.519
So the easiest example is, or a couple examples, if you have the string A, B, C, C, B, A, the two characters that have the largest distance between them are the a at the beginning of the string and the a at the end.
00:07:07.680 --> 00:07:12.879
And because there's B C C B in between those, that's four characters, so the answer is four.
00:07:13.040 --> 00:07:20.560
If you have the string AABC, there are three pairs that all have the largest distance, which is zero.
00:07:20.720 --> 00:07:24.800
And if you have the string ABC with no duplicates, you return a negative one.
00:07:25.040 --> 00:07:29.040
And so if you want, we can ignore the negative one uh for a while.
00:07:29.199 --> 00:07:46.399
But even just the uh, you know, assuming that there is a duplicate, how to well actually I guess the negative one is the tricky part because if you were to do something like my uh my thought process, and then I'll let the pros uh step in, was that you want to use where or indices to do this.
00:07:46.639 --> 00:07:49.439
Um something, well, is that actually true?
00:07:49.600 --> 00:07:50.639
Or classify?
00:07:50.800 --> 00:07:58.879
I can't remember now that I I I guess I should have uh, but there's some operation basically where you want to get um well actually uh okay, I gotta step a step back.
00:07:58.959 --> 00:08:02.399
Let's actually walk through this if I'm solving this for the first time because clearly I've forgotten.
00:08:02.560 --> 00:08:04.959
I think at one point I was like, let's do an outer product.
00:08:05.040 --> 00:08:31.040
If you get a unique with the um values in your or the characters in your string, you can then get like a uh matrix where you have a mask that corresponds for ones for all equal values, and if you did an indices on that and then some kind of um you know two y's minus reduction, you could then get the differences, but then you're gonna run into issues with that.
00:08:31.279 --> 00:08:35.919
And then I I I think I had an alternate version with where, but it still wasn't great.
00:08:36.000 --> 00:08:55.039
And the problem is that if you are going to do the first last trick, so if you even if you take that matrix index idea and you look at the first value or the first index and the last index, you're not gonna get the correct value if you only have a single character in the case of the ABC string.
00:08:55.120 --> 00:09:00.159
Uh because the first and the last both point to the same one, and they can't both point to the same one, right?
00:09:00.240 --> 00:09:05.679
So you have to do some kind of check to make sure there's at least two indices that correspond to equal values.
00:09:05.840 --> 00:09:07.440
Um and yes, someone in the chat.
00:09:08.159 --> 00:09:09.519
That's just checking.
00:09:09.759 --> 00:09:14.080
Like you know that that if they have the same if they have the same position, right?
00:09:14.159 --> 00:09:18.320
Because it's the f the first and left are the same, then the distance between them is going to be zero.
00:09:18.480 --> 00:09:22.960
So it's only a problem if there aren't any duplicates at all, right?
00:09:23.360 --> 00:09:23.679
Correct.
00:09:23.919 --> 00:09:26.639
Although now that's super easy to check.
00:09:27.200 --> 00:09:31.759
We have to subtract what I think is like a difference of zero already is invalid.
00:09:31.919 --> 00:09:33.919
Like it has to be a difference of yeah.
00:09:34.240 --> 00:09:39.120
So you just if there's if there's I mean, if this a just simply because a then the answer is zero, right?
00:09:41.360 --> 00:09:42.240
Are you still looking for it?
00:09:42.799 --> 00:09:43.279
Oh yeah, yeah.
00:09:43.440 --> 00:09:49.120
Uh some of the comments says straight oh largest same digits number, but I'm not sure it's that.
00:09:49.600 --> 00:09:50.480
Uh but hold on.
00:09:50.960 --> 00:09:53.360
Uh let that's just just to think about this.
00:09:53.519 --> 00:10:01.840
If if the string is aa, then the the first and the last indices, right, should be one apart.
00:10:02.000 --> 00:10:03.840
But the actual answer we should give is zero.
00:10:04.240 --> 00:10:05.440
So we just subtract one, right?
00:10:05.519 --> 00:10:05.679
Right.
00:10:05.759 --> 00:10:06.080
And then the one that's a little bit different.
00:10:06.240 --> 00:10:12.799
Now the only way to get the only way to get the largest distance being zero if if every character is unique.
00:10:13.039 --> 00:10:16.799
So all we need to do is subtract one and then we get negative one.
00:10:17.039 --> 00:10:18.000
Isn't that super easy?
00:10:18.480 --> 00:10:18.879
That's so sad.
00:10:18.960 --> 00:10:19.440
Yeah, yeah, yeah.
00:10:19.600 --> 00:10:30.960
So this corner case that I thought made it tricky, it's actually super simple because you're gonna have to subtract one from everything, and the case where it's zeroed actually gives you the exact value that you need.
00:10:31.360 --> 00:10:34.879
So I think that I have a solution in in dialog API.
00:10:34.960 --> 00:10:35.919
If you want me to share my screen.
00:10:36.159 --> 00:10:36.559
Yeah, yeah, yeah.
00:10:36.960 --> 00:10:40.080
And so there was someone in the chat that was mentioning a different problem.
00:10:40.240 --> 00:10:41.759
It definitely wasn't that problem.
00:10:41.919 --> 00:10:51.120
Uh and yes, we were saying that we pro weekly challenge recently vibe coded their an upgrade to their website, and we can't find a list of the last problems.
00:10:51.279 --> 00:10:58.159
The hack that I was doing is if you go to this week, it shows you a full URL with uh weekly or week 374.
00:10:58.559 --> 00:11:05.600
If you just change those URLs to 373, 372, 371, which is what I was doing, but I couldn't figure out.
00:11:05.759 --> 00:11:08.320
Um, I still couldn't find the exact problem statement.
00:11:08.399 --> 00:11:09.600
But it was in the last month or two.
00:11:09.679 --> 00:11:15.120
So if you uh you know YouTube viewers want to go and try and find the link, paste it, we will we will then share it with folks.
00:11:15.279 --> 00:11:16.480
Uh we don't know which week this is.
00:11:16.799 --> 00:11:21.279
I was immediately thinking uh Adam's sharing a screen and it's got the the key operator.
00:11:21.360 --> 00:11:24.879
As soon as you described the problem, I was immediately thinking key in my head.
00:11:25.200 --> 00:11:34.960
Um where the default gives you the indices where unique major cells and in this case unique elements occur.
00:11:35.039 --> 00:11:37.039
And that's that's what you're concerned with, right?
00:11:37.120 --> 00:11:38.879
So the indices of elements.
00:11:39.279 --> 00:11:57.039
Yeah, well, I was concerned that if you like, like I said, like it's actually ironic that I thought this one was tricky because the problem statement actually is perfect in that getting the negative one is a natural byproduct of actually subtracting one from the deltas between the indices.
00:11:57.279 --> 00:12:06.480
So like what I thought, and I thought that was the tricky part because you had to deal with that some way, but it's actually it falls out of just dealing with the the general case.
00:12:06.720 --> 00:12:14.320
And uh the interesting thing is though that both of you thought of key, whereas I guess I don't reach for key rarely ever.
00:12:14.480 --> 00:12:16.159
I always think about I don't know.
00:12:16.480 --> 00:12:17.279
Doesn't do a lot of groups.
00:12:17.440 --> 00:12:19.360
You basically said it, you said classify, right?
00:12:19.600 --> 00:12:23.200
Yeah, you said classify, and that is what it does.
00:12:23.519 --> 00:12:29.120
Classify is not an APL though, so this is it fulfills the same role, right?
00:12:29.200 --> 00:12:31.600
It takes these and puts them into takes all the A's.
00:12:31.759 --> 00:12:39.840
So the way I thought it was key anyway, because we're not interested in A in relation to any other letter than A.
00:12:40.000 --> 00:12:47.600
So classify was that the once upon a time a monadic equals in some writings that would give you that matrix.
00:12:47.679 --> 00:12:48.320
It's like a character.
00:12:48.879 --> 00:12:50.320
Yeah, things matrix.
00:12:51.279 --> 00:12:51.840
Yeah, okay.
00:12:51.919 --> 00:12:52.240
Yeah.
00:12:52.559 --> 00:12:54.000
So this is exactly what I said, right?
00:12:54.080 --> 00:12:58.240
I said, yeah, like a unique uh this is what they had to do before key.
00:12:58.480 --> 00:12:59.679
Ease before key.
00:13:00.159 --> 00:13:00.399
Yeah.
00:13:00.720 --> 00:13:10.320
So actually, so let's this is amazing, but we uh like I'm very excited because this is I you know, uh did we have a topic for today, you know, uh Adam and I were trying to figure out, and I was like, well, what are you talking about?
00:13:10.559 --> 00:13:18.639
I know, I know, but I thought in my head, I was like, well, there's not anything like topical news or and we didn't have time to set up a guess because I've been I've been out of the country for the last uh week.
00:13:18.799 --> 00:13:27.120
But I was thinking, you know what I actually want to do is I want to ping, I want to I want Adam to solve this problem that I like in my head a month ago couldn't like come up with an elegant solution for.
00:13:27.200 --> 00:13:31.279
And now we've got like three different solutions, or at least two.
00:13:31.440 --> 00:13:39.279
Uh, but let's so let's take a step back and walk people through the uh the first uh and so someone I think has found it.
00:13:39.519 --> 00:13:50.639
Task two, they haven't mentioned the day, but the exact wording of the problem is you're given a string, write a script to return the length of the largest substring between two equal characters, excluding the two characters.
00:13:50.799 --> 00:13:53.279
Return negative one if there is no such substring.
00:13:53.440 --> 00:13:57.840
So I I stated it slightly differently, but it was just an alternate description of the same problem.
00:13:58.960 --> 00:14:02.480
The only problem is if it's empty, then things will end up.
00:14:02.639 --> 00:14:06.159
D Z and Naroli, if you'd like to say what week that was.
00:14:06.320 --> 00:14:09.120
Um yes, that is the exact problem that we are talking about.
00:14:09.200 --> 00:14:14.399
If you say the week, we will uh we will mention it for the audio listeners, obviously everyone on YouTube at this point.
00:14:14.559 --> 00:14:18.960
So yeah, walk us through starting with key, because I'm sure there's people in the chat.
00:14:19.039 --> 00:14:23.840
Uh because like I said, I I rarely reach for key, but it is in this case exactly what you wanted.
00:14:24.080 --> 00:14:26.240
Yeah, so let's take this this simple example here.
00:14:26.399 --> 00:14:30.639
We've got uh ABCAA uh with key.
00:14:31.039 --> 00:14:37.600
And uh we're just going to inspect what uh what the elements are going uh are going to be.
00:14:37.759 --> 00:14:41.519
So the way it works is the key uh what the argument is going to be.
00:14:41.679 --> 00:15:06.879
Um the key will classify well, it will it will take the col the um array on the right as a collection, and it will punch together all the equal elements, and it will call the function on its left with that element uh or that um that major cell really uh as left argument, and the right argument is going to be the list of indices where those appear, right?
00:15:07.120 --> 00:15:12.320
So we see A appears at these places, b at these places, c at these places.
00:15:12.559 --> 00:15:16.720
Now we're not actually interested in the element itself, so we can get rid of that.
00:15:16.799 --> 00:15:30.720
We're just interested in the in the indices of individual um elements, and then we wanted to find the location of the uh uh the largest and the the first one and the last one, and then subtract them.
00:15:30.799 --> 00:15:35.919
So this is the so the max reduction and the min reduction, and subtract the two.
00:15:36.320 --> 00:15:37.759
Wow, you walk people through that.
00:15:38.000 --> 00:15:41.279
I assume they uh know a little of AP, but they're shocked by you.
00:15:41.600 --> 00:15:44.080
Whoa, what is this incantation that you managed to okay?
00:15:44.159 --> 00:15:44.960
So this is the fork.
00:15:45.200 --> 00:15:48.399
So this is the the maximum reduction on the list.
00:15:48.559 --> 00:15:58.480
This gives the last time anything appears, and this is the uh minimum reduction, so the first time it appears, which could be the same, of course, if there's if there's only one.
00:15:58.799 --> 00:16:06.080
And to be clear, the reason you're saying first and last is because a property of these indices is that they're gonna be sorted.
00:16:06.399 --> 00:16:08.879
Uh yeah, of course they're in there, they're sorted, they're sorted there.
00:16:09.039 --> 00:16:12.159
But it doesn't matter, even if they weren't sorted, I'm actually not getting the first and last.
00:16:12.240 --> 00:16:14.960
I'm actually getting the maximum and minimum.
00:16:15.039 --> 00:16:16.720
So I can actually make this shorter matter.
00:16:17.279 --> 00:16:24.080
It's the maximum min glyphs, but you were saying first and last, which yeah, it's going to be the if you're not staring at the screen.
00:16:24.240 --> 00:16:28.240
Uh you could also in a moment for that reason.
00:16:28.399 --> 00:16:29.919
Uh what do you say, Richard?
00:16:30.159 --> 00:16:32.799
You could use first and last in this case for that reason.
00:16:33.039 --> 00:16:34.879
Yeah, it's just it's but it's sorted.
00:16:35.200 --> 00:16:44.000
It's easier to reason about it like this, but but we can change it to then and we don't have a math if you're gonna do first and last because it wouldn't be able to compute anything.
00:16:44.240 --> 00:16:44.720
That's true.
00:16:44.960 --> 00:16:46.240
We can go half later.
00:16:46.399 --> 00:16:47.679
Well woo, half later.
00:16:47.840 --> 00:17:02.639
Uh okay, so and and what happened over here is basically just in mathematics that if you've got uh f of x plus uh g of x, then you're allowed to write that as f plus g of x.
00:17:03.120 --> 00:17:04.880
So I use that over here.
00:17:05.039 --> 00:17:11.920
So this is the the max of the right argument minus the uh min of the argument.
00:17:12.160 --> 00:17:16.079
So that's what's happening here, and that gives us that gives us these.
00:17:16.160 --> 00:17:19.440
Uh we don't actually need the enclose anymore because they're all scalar values.
00:17:19.599 --> 00:17:35.839
Um and then we wanted to uh subtract one, so because we consider adjacent as having a string of length zero between them, so that gives us all these, and then we want to find the maximum value, and if there are only negative ones, of course it becomes negative one.
00:17:36.160 --> 00:17:41.599
So this is the this is the full solution, and this can be written locally in a tacit way as well.
00:17:41.839 --> 00:17:45.839
Uh so we can try that, and then we can try it on these.
00:17:48.480 --> 00:18:00.319
Um and now because these are max, I mean actually they're actually sorted, we can replace the in the in Dalegap, we can replace the minimum with the first cliff, which is fine.
00:18:00.480 --> 00:18:02.960
Uh it doesn't really matter.
00:18:03.440 --> 00:18:06.880
Um And there's some more things we can do.
00:18:07.039 --> 00:18:18.160
We can because this is just applying a function on the argument, but we had it has to be the right argument, so we can just say that we apply we composing these at the top.
00:18:18.319 --> 00:18:26.079
So we say we want this function applied to the result of uh the function that selects the right argument, it can also the left argument.
00:18:26.400 --> 00:18:28.559
So that's this also works.
00:18:28.880 --> 00:18:32.640
Uh it would be so nice if we had a last glyph, wouldn't it?
00:18:34.319 --> 00:18:35.839
Maybe later we'll I'll solve this.
00:18:35.920 --> 00:18:48.559
Well, I'll attempt to solve this in Tiny Apple because not only do they have uh yeah, the first and last, but they also have I believe Classify, which there's yeah, uh Rich is in the chat.
00:18:48.640 --> 00:18:49.920
I was also thinking the same thing.
00:18:50.000 --> 00:18:55.920
So Max has said that IOTA self uh is classify in BQN or swap.
00:18:56.079 --> 00:19:02.079
I'm not sure which one it is, but Iota is um not in uh BQN.
00:19:02.240 --> 00:19:15.519
They have the range glyph, but I'm pretty sure classify is actually one of like the I can never remember, but they they have like the claws or like the open boxes on their sides and the underbar open boxes on their sides.
00:19:15.759 --> 00:19:17.759
One of those I'm pretty sure is classify.
00:19:18.079 --> 00:19:20.480
And in fact, yeah, this is classifying, right?
00:19:20.640 --> 00:19:23.599
That that's the I think that's what theme god is trying to say.
00:19:25.279 --> 00:19:31.680
So here I'll put in the I'm not sure if uh the uh so you want to you want to group by the classif self-classification here, right?
00:19:32.079 --> 00:19:39.200
Um that's another way another way to get the the indices here, but uh but key is of course very nice.
00:19:40.720 --> 00:19:52.880
So there is a participant in the chat with a name that I find difficult to pronounce, spelled underscore underscore dash kd eight o z or is it e depending on the s.
00:19:53.279 --> 00:19:54.240
We'll just call them ours.
00:19:56.160 --> 00:19:57.359
Kd eight oz.
00:19:57.759 --> 00:20:11.200
Um uh and uh try to translate it to J that looks to to a j solution that we can I can put here in the just paste it in yesj if we were on Ray Box we could actually evaluate it.
00:20:11.440 --> 00:20:16.720
But I this seems overly overly complicated because J has key.
00:20:16.880 --> 00:20:21.759
Now I'm not an expert on using it, but so wait, wait, let's walk because this is exactly this is interesting, right?
00:20:21.839 --> 00:20:35.839
This was the and we're gonna solve this in dialogue APL this way as well, because you before I said let's slow down and walk people through the first solution, you showed the unique without a product, and the next step would be to do like an indices on each of the rows.
00:20:36.079 --> 00:20:40.160
And my j foo is not great, but basically that's what that looks like, right?
00:20:40.240 --> 00:20:41.680
You've got a I yeah.
00:20:41.759 --> 00:20:49.839
So if we do if we do like a unique um the U Oz just said uh it's a randomly generated name.
00:20:50.319 --> 00:20:51.680
Don't let it befuddle you.
00:20:51.759 --> 00:20:53.920
And the thing is that I don't know how to use key and j.
00:20:54.079 --> 00:20:55.039
So here we go, folks.
00:20:55.200 --> 00:20:59.200
We're taking key and j for a spin, although we're still in dialogue EPL.
00:20:59.279 --> 00:21:00.400
So we'll we'll get dialogue.
00:21:01.599 --> 00:21:09.440
If you do the indices here for these, so we want each row, we want to do the max index and the min index, right?
00:21:09.599 --> 00:21:11.839
That would that would work as well.
00:21:12.000 --> 00:21:13.759
So we can s we can try this.
00:21:13.839 --> 00:21:31.599
So on each row, we want to get uh the uh the index of the la uh well, so we want the indices and then we want the max minus minus the min, which is of course the first and the last, the same thing.
00:21:32.079 --> 00:21:32.720
Like this.
00:21:33.119 --> 00:21:36.400
So that then we're up to the step and we can continue from there.
00:21:36.880 --> 00:21:46.000
Can't you I guess right, you don't have but technically you don't have uh cells, like you don't have a shortcut for rank one.
00:21:46.480 --> 00:21:48.319
No, but it wouldn't help much either.
00:21:48.640 --> 00:21:48.799
Right.
00:21:48.880 --> 00:21:52.640
I was I was gonna say I was thinking is there some way to do the shorter, but I think this probably is the short.
00:21:53.440 --> 00:21:58.720
There is because you can you could do you can do trickery with nested arrays, we can do this, right?
00:21:59.039 --> 00:22:10.640
Because of how Net how um scalar functions penetrate into structure, so then we make the whole thing a scalar, and then we get the unique, which is another vector.
00:22:10.720 --> 00:22:14.240
So vector equals scalar, it gets the whole scalar gets paired up with each one.
00:22:14.319 --> 00:22:15.920
So now we've got these three, right?
00:22:16.000 --> 00:22:23.440
So those are just the rows of this same thing as splitting this into its constituent cells, and now the rank one has magic.
00:22:23.519 --> 00:22:25.440
You just you just blew through this.
00:22:25.599 --> 00:22:30.720
Whoa, so now we can just do an each on this instead, and we get the same thing.
00:22:30.799 --> 00:22:32.400
So that's slightly shorter.
00:22:33.279 --> 00:22:39.279
So step back to uh so you've got in a fork unique equal enclose.
00:22:39.759 --> 00:22:43.680
Yeah, because if you think about it, if let's start with not unique.
00:22:43.920 --> 00:22:54.000
I'm thinking about it, but uh and and uh an identity function equals the in-close is so the in-close makes this whole thing into a single scalar, right?
00:22:54.079 --> 00:22:56.240
It's a nested scalar, but it's a single scalar.
00:22:56.559 --> 00:22:58.799
So now we've got vector equals scalar.
00:22:58.960 --> 00:23:05.839
I mean, so we know the result will be a vector where we take this entire scalar and pair it up with every element of the vector.
00:23:06.000 --> 00:23:09.680
Now the every element of the vector was those original letters.
00:23:10.160 --> 00:23:14.160
So we compare every letter with the entire vector.
00:23:14.319 --> 00:23:16.079
So that gives us this.
00:23:16.240 --> 00:23:21.200
This is the outer same thing as outer equality, but in a nested form instead of a rank form.
00:23:21.440 --> 00:23:29.759
And if we replace the density function with the unique elements, that's the same thing as the outer product, but in nested form.
00:23:30.079 --> 00:23:31.519
So this is that is beautiful.
00:23:31.599 --> 00:23:36.880
That's the same thing basically as a mix of the outer product that you have before, right?
00:23:37.119 --> 00:23:40.640
That's a split split split of this or mix of this, right?
00:23:41.519 --> 00:23:43.359
I can never uh I can never keep which ones.
00:23:43.839 --> 00:23:50.799
So a split of split splits it into individual uh rows and mix mixes together the rows into a single array, right?
00:23:50.960 --> 00:23:57.839
A single yeah, and technically you can put the split into the the tacit expression up there, and you can do the same thing.
00:23:58.000 --> 00:24:03.519
So really it's there's no point I know, but it's a two like if you want to assign these to a function.
00:24:03.839 --> 00:24:08.880
Oh actually, yeah, and then and but if you're and if you're golfing, this is basically like a two-character saving.
00:24:08.960 --> 00:24:13.440
So if you ever find yourself uh splitting uh oh right, then you can outer product.
00:24:14.240 --> 00:24:20.880
If you actually want the outer product, then it's shorter to write this than it is to write the equivalent, right?
00:24:21.039 --> 00:24:29.279
You save your one character, even though it's very silly, and it just looks beautiful, like the the rotated rotated horseshoe.
00:24:29.359 --> 00:24:35.200
Oh my god, the the the forks that look a bit like faces, yeah.
00:24:35.440 --> 00:24:36.160
I mean, I can't.
00:24:36.319 --> 00:24:39.680
I don't know if I can see an expression this guy, it's elegant as hell.
00:24:40.480 --> 00:24:44.079
Okay, so so and then we're just we just do the each here, right?
00:24:44.480 --> 00:24:46.880
Because now we have a nested form, we don't need to do rank one.
00:24:47.119 --> 00:24:59.759
So we essentially got the major cell cells for operator because now we're just operating on uh individual elements, and being that the result of this is a simple scalar, it all just collapses back.
00:25:00.319 --> 00:25:07.519
This wouldn't work in the in a boxed array model, but it does work here uh because of uh dialogue APL's floating arrays.
00:25:07.759 --> 00:25:09.519
But there's a there's more we can do actually.
00:25:09.599 --> 00:25:24.160
I was just thinking here because if we look at if we go back here and look at this, there's a fun thing that we actually just want uh the the largest one and subtract the first one.
00:25:24.559 --> 00:25:30.000
So uh what if we could find the position of the last one in a more direct way?
00:25:30.079 --> 00:25:33.519
And the position of the first so the position of the first one is actually interesting, right?
00:25:33.599 --> 00:25:34.720
Because that we find here.
00:25:35.279 --> 00:25:40.720
The position of the first A is one, the position of the first B is two, the position of the first C is three.
00:25:41.759 --> 00:25:44.880
So I mean it doesn't matter that we're doing the computation multiple times.
00:25:45.200 --> 00:25:48.000
How can we find the position of the last one?
00:25:48.079 --> 00:25:59.359
Well we can sort of do it by uh looking into into the reverse, but it's not quite, because then we get the position from the end instead.
00:25:59.680 --> 00:26:09.680
Okay, so so uh one is this one, and then then the B we find at position five, but from from the end.
00:26:10.000 --> 00:26:26.559
So if you subtract this from the the total length, then we can see that the last A is in position five, one, two, three, four, five, actually six, but off by one because we cut counting positions here compared to the um, but that doesn't matter so much.
00:26:26.880 --> 00:26:42.880
So this gives us the last position, and this gives us the first position, which means if we subtract the two, and then it will be the wrong uh the wrong uh sign, but that doesn't matter so much because we can easily just swap things around here.
00:26:43.279 --> 00:26:44.960
Oh sorry, did I do the wrong thing?
00:26:45.440 --> 00:26:48.079
Uh sorry, it should be like this instead.
00:26:48.799 --> 00:26:49.519
Is this right?
00:26:50.240 --> 00:26:52.000
Yeah, these give negative one, right?
00:26:52.079 --> 00:26:57.920
Because those are the ones that don't have any duplicates, and then we just want the largest uh value that we've got here.
00:26:58.480 --> 00:27:00.799
So one, two, three, four.
00:27:00.960 --> 00:27:02.400
That's the distance over here.
00:27:02.480 --> 00:27:04.960
So the the off by one error came to our advantage.
00:27:05.039 --> 00:27:06.400
We don't have to do that adjustment.
00:27:06.799 --> 00:27:12.000
So this is a this is a solution where we directly look for the first and the last, and we don't do the whole key thing.
00:27:12.160 --> 00:27:13.680
It's probably faster.
00:27:14.640 --> 00:27:21.359
In fact, we we wouldn't actually need to do it on all of them, we could just do it on the unique ones, but yeah, that's fine.
00:27:21.519 --> 00:27:22.640
Do you need to go through it again?
00:27:22.799 --> 00:27:23.839
See what just happened here?
00:27:24.160 --> 00:27:27.519
Well, and also this is only a solution for a subset of the problem, right?
00:27:27.680 --> 00:27:29.200
It doesn't handle the negative one case.
00:27:29.440 --> 00:27:29.920
Why not?
00:27:30.079 --> 00:27:32.079
You see, the negative one came out here.
00:27:32.319 --> 00:27:33.200
Yeah, because we come.
00:27:35.200 --> 00:27:38.640
I got three different selfie slash commute squiggles.
00:27:38.720 --> 00:27:41.039
This looks like absolute nonsense.
00:27:41.200 --> 00:27:43.519
Uh you you're the one that liked the combinators.
00:27:44.079 --> 00:27:44.400
No, I know.
00:27:44.480 --> 00:27:48.000
I say this from a place of combinator combinatory logic love, folks.
00:27:48.079 --> 00:28:06.960
I'm just saying we were we were dealing with the beautiful, unique equals enclose fork idiom that I just learned, and uh, I'm sure I could have used many times before, and then Adam was like, Oh yeah, well, hold my beer, and he was like, selfie, selfie, selfie, you know, and uh and then somehow had the right answer.
00:28:07.039 --> 00:28:07.839
Uh okay.
00:28:08.160 --> 00:28:10.079
Okay, so so here's the thing.
00:28:10.319 --> 00:28:11.839
Um, it just came out right.
00:28:11.920 --> 00:28:13.920
I hadn't planned it, it's just developing.
00:28:14.240 --> 00:28:18.079
But so this one you understand, this is sort of a classify thing, right?
00:28:18.319 --> 00:28:22.079
Because really, the dyadic iota, right?
00:28:22.240 --> 00:28:36.240
The index of has a built-in unique that we don't think about, but it's important here because what's actually happening is it only looks for the first position of any one element, so there's actually unique here, right?
00:28:36.400 --> 00:28:51.039
It's the only thing that's not this would give the same result if it's unique, but if we had like an F at the end, so we can't get rid of these, but they're not considered, nothing will ever give indices, there's nothing we put over here that will give indices four, five, six, right?
00:28:51.279 --> 00:28:54.799
I guess I the problem is I never use dyadic iota, I don't think for like anything.
00:28:54.880 --> 00:28:57.119
So I I don't even okay.
00:28:57.440 --> 00:29:01.519
And like in my mind, suboptimally, but like I just don't reach for dyadic iota.
00:29:01.680 --> 00:29:02.559
Uh okay.
00:29:02.640 --> 00:29:19.279
Well, I mean, we look we've we have real customers like at doing things, and APL has this huge toolbox of amazing things you can do, but I would say most applications out there they just look for information and retrieve information, don't like and then do a little bit with it.
00:29:19.440 --> 00:29:21.920
And looking for information, that's diet.
00:29:22.880 --> 00:29:25.279
Retrieving information, that's indexing.
00:29:25.440 --> 00:29:30.240
That's that's like 90% of what business applications do, looking things up and extracting it.
00:29:30.559 --> 00:29:38.160
Well, what is uh what is tiny apple because did tiny apple borrow um they borrowed the membership?
00:29:38.400 --> 00:29:41.839
Uh well I guess I can well I don't wanna but anyways, yeah.
00:29:42.160 --> 00:29:43.599
Anyway, let's let's let's go through this.
00:29:44.079 --> 00:29:44.880
I'll explain it.
00:29:45.039 --> 00:29:48.240
Okay, so index off it returns the first index off.
00:29:48.480 --> 00:29:50.720
Like it even exists in like JavaScript, there's an index off.
00:29:50.880 --> 00:29:52.559
That's dietic author, right?
00:29:52.880 --> 00:29:54.000
Uh sorry, say again.
00:29:54.240 --> 00:29:56.880
Say index off even exists in like JavaScript.
00:29:57.039 --> 00:29:58.960
And it's the same basically definition.
00:29:59.039 --> 00:30:01.759
The only difference is what if it's not found, but that doesn't matter here.
00:30:02.000 --> 00:30:04.400
Well, so I think the problem is that maybe that's this is what I'm thinking.
00:30:04.480 --> 00:30:10.960
Uh, because tiny apple has both index of and uh this one's called element of.
00:30:11.359 --> 00:30:15.359
And if those are the same thing and tiny apple has borrowed no, that's not the same thing.
00:30:15.599 --> 00:30:18.000
Element of is is is this, right?
00:30:18.079 --> 00:30:18.799
Oh, sorry.
00:30:18.960 --> 00:30:19.200
Right?
00:30:19.279 --> 00:30:20.319
That's if it's a member.
00:30:21.680 --> 00:30:27.599
Uh did you just type that, but it's not a member, it's not in uh dialogue APL membership?
00:30:27.839 --> 00:30:30.319
No, it's using uh new font.
00:30:30.480 --> 00:30:32.240
Okay, so this is no, so I okay.
00:30:32.400 --> 00:30:36.480
I'm not uh I was just trying to maybe think that like maybe I use it all the time but in a different language.
00:30:36.640 --> 00:30:39.039
But yeah, for whatever reason, I just don't use Diata Coyota.
00:30:39.200 --> 00:30:43.680
I don't know, I don't know why what I'm what I'm doing in the cases where you need it, but anyways, continue.
00:30:44.559 --> 00:30:46.880
We need to look up the position of something, right?
00:30:46.960 --> 00:30:48.960
So we're looking up the position of everything itself.
00:30:49.200 --> 00:30:59.200
So that's essentially has like a sort of a uh a nerfed unique inside because we only consider the the first time an element appears.
00:30:59.359 --> 00:31:03.519
So all the a's get mapped to position one that is there, right?
00:31:04.240 --> 00:31:07.759
So this so automatically this gives us the first position.
00:31:07.839 --> 00:31:16.079
I'm I'm using this property that I that's diadegayota will give us the first location of any one element to get the first locations of all the elements.
00:31:16.160 --> 00:31:22.400
So this is all these numbers are the first occurrences of all the elements, right?
00:31:22.640 --> 00:31:26.319
Then I want I want a variation on on diadega yota.
00:31:26.720 --> 00:31:30.880
I want the one that gives me the last position, but that's not built into the language.
00:31:31.200 --> 00:31:33.279
Then I'm constructing that piecemeal.
00:31:33.359 --> 00:31:34.720
So how can I find that?
00:31:34.880 --> 00:31:39.599
Well, let's say we start by uh by reversing instead, right?
00:31:39.839 --> 00:31:44.480
So if we reverse, then we're looking up, think of this one as being reversed.
00:31:44.559 --> 00:31:50.079
So we're so this is position one, f, this is position two, this is position three, and so on.
00:31:50.559 --> 00:31:52.799
So a gets mapped to two, okay.
00:31:53.039 --> 00:31:54.480
F A, right?
00:31:54.799 --> 00:31:57.839
And b gets mapped position six because we're counting from the right.
00:31:58.160 --> 00:32:03.440
But we can't compare indices counting from the left with indices counting from the right.
00:32:03.599 --> 00:32:07.759
So how do you how do you swap which direction an index is counted from?
00:32:08.160 --> 00:32:13.839
You do that by subtracting them from the total length, and then you have an off by one error, but I'm not worried about that.
00:32:14.559 --> 00:32:22.160
So basically, position five from the end is position length minus five from the beginning.
00:32:22.480 --> 00:32:23.200
Are you with me?
00:32:23.359 --> 00:32:25.920
Yeah, okay, so that's exactly what I'm doing.
00:32:26.079 --> 00:32:30.079
So we'll take these numbers and we'll subtract them from the length.
00:32:30.160 --> 00:32:32.880
So we'll take the string again and subtract.
00:32:33.039 --> 00:32:35.440
Okay, this is the position from the beginning.
00:32:35.680 --> 00:32:40.240
So the f the last a is in position five, except we have an off by one error, but that doesn't matter.
00:32:40.480 --> 00:32:43.599
Position one, two, three, four, five.
00:32:43.680 --> 00:32:44.720
So yeah, off by one.
00:32:44.880 --> 00:32:47.359
But since it's consistent, I'm not worried about it at this point.
00:32:47.599 --> 00:32:51.680
Really, we want because of fence post, whatever, we want to add uh add one.
00:32:52.160 --> 00:32:54.559
These are zero indexed now.
00:32:55.119 --> 00:32:56.079
Okay, great.
00:32:56.640 --> 00:32:59.440
So we have the indices here.
00:33:00.240 --> 00:33:03.519
And we do uh actually it's the other way around, but it doesn't matter.
00:33:03.680 --> 00:33:06.720
So we're subtracting the last position, right?
00:33:06.799 --> 00:33:09.440
So sorry, we're subtracting the first position from the last position.
00:33:09.519 --> 00:33:13.359
That's why I'm commuting the the minus, and that gives us these numbers.
00:33:13.440 --> 00:33:20.480
And luckily, we needed to we're off by one, but we needed to subtract one anyway for the problem statement, so it all works out, just happens to be.
00:33:20.640 --> 00:33:24.880
And from here on, everything is like we did before, we just need the max value.
00:33:25.200 --> 00:33:26.240
So all good.
00:33:26.400 --> 00:33:29.599
Now, of course, this is longer than this.
00:33:29.680 --> 00:33:32.240
So I'll just show you how we how we get there.
00:33:32.480 --> 00:33:35.759
Okay, so everything notice that this works out very nicely as a train.
00:33:35.839 --> 00:33:41.839
Immediately we can see that because uh we've got a bunch of functions and all the arguments are the same, right?
00:33:42.079 --> 00:33:46.160
So if we try to first define this as a def and nothing, then it makes it easier to see.
00:33:47.279 --> 00:33:47.519
Right.
00:33:47.599 --> 00:33:49.920
So we'll let's let's just do that down here.
00:33:50.160 --> 00:34:06.960
We'll put the argument uh out over here and replace them with omega so we can because annotation is really important, and being able to just spot the patterns much easier if you have a symbol than if you have a whole uh distracting uh string.
00:34:07.599 --> 00:34:11.519
Okay, get rid of all those pesky spaces because they're also just distracting.
00:34:11.840 --> 00:34:13.199
Okay, so all good.
00:34:13.280 --> 00:34:13.679
This works.
00:34:13.840 --> 00:34:15.599
We can even try it with all our test cases.
00:34:15.679 --> 00:34:23.039
We do it on this one, we do it on the ABC one, and we do it on the one with like the all the JSON necklace, right?
00:34:23.440 --> 00:34:25.519
Shouldn't this give zero by the way?
00:34:25.840 --> 00:34:27.679
Uh no, no, I think that's right.
00:34:27.760 --> 00:34:30.639
It's uh it's the still yeah, it's why there's one in between.
00:34:30.719 --> 00:34:31.840
Yeah, it's not AA, right?
00:34:32.000 --> 00:34:37.199
It's just uh yeah, we can do one more that's Rich with the save with the save there, Rich.
00:34:37.360 --> 00:34:37.920
I like that.
00:34:38.400 --> 00:34:39.519
I was also thinking the same thing.
00:34:39.599 --> 00:34:44.239
I was like, oh yeah, yeah, because I changed the case one before it wasn't AA, right?
00:34:44.400 --> 00:34:45.760
Okay, so now we go through this.
00:34:45.840 --> 00:34:47.440
So this one is a selfie, right?
00:34:47.519 --> 00:34:48.639
You should you spot that.
00:34:48.880 --> 00:34:51.119
So this isn't a commute, this is actually a selfie.
00:34:51.360 --> 00:34:52.159
We'll do that.
00:34:52.320 --> 00:34:59.599
This is the length, we leave that for now, and this this pattern is exactly the new thing in version 20 of dialogue, right?
00:34:59.679 --> 00:35:01.280
We with the behind operator.
00:35:01.599 --> 00:35:04.320
Sigma combinator, and this favor.
00:35:05.039 --> 00:35:07.360
So we can type this like this, okay?
00:35:07.440 --> 00:35:08.800
So this is our next step.
00:35:08.880 --> 00:35:19.039
I should give the same thing, and at this point, we're basically ready to go to go test it because we we now have one, two, three functions that are uh applied to the argument.
00:35:19.199 --> 00:35:24.960
We have got intervening functions with them here, and then we got an atop with the last one, which just works out beautifully.
00:35:25.119 --> 00:35:29.199
So get rid of that one, get rid of this one, I'll get rid of the parentheses later.
00:35:29.760 --> 00:35:30.960
There we there we go.
00:35:31.119 --> 00:35:34.559
And now we get rid of the parentheses like that.
00:35:34.800 --> 00:35:35.119
Yeah.
00:35:35.599 --> 00:35:37.440
Max has a great suggestion.
00:35:37.599 --> 00:35:39.360
Can you uh inline trace?
00:35:42.800 --> 00:35:45.679
I'm interested to see how uh whether this clarifies enough.
00:35:46.000 --> 00:35:48.719
So this is the new inline tracing in version 20.
00:35:48.960 --> 00:35:54.320
Uh, we can make this a bit bigger so we can see that there's this is the argument in array notation.
00:35:54.719 --> 00:36:00.480
And so we this is the function here, and it's being given this right argument.
00:36:00.719 --> 00:36:07.280
Uh we're now stepping into it, it's parsing through this basically, step by step of the train that's working so far.
00:36:07.519 --> 00:36:10.239
Stepping into this, which is just a derived function.
00:36:10.480 --> 00:36:14.159
Finally, we're going to remember it's it's behind.
00:36:14.239 --> 00:36:21.519
So first we apply the reverse on this argument, and then we can say now this one is being applied dyadically, so it opens the window over on the left.
00:36:21.679 --> 00:36:23.039
It's working beautifully so far.
00:36:23.199 --> 00:36:37.440
So now we're looking up the right direction array into its reverse, and uh then we are applying the um the length here, doing the subtraction, seven minus all these indices we computed before.
00:36:37.840 --> 00:36:45.679
Then we go find the selfie, we step into that, so we can see that's the same argument being applied twice with the right and left arguments of iota.
00:36:46.320 --> 00:36:57.440
That gives us all the selfie uh indices, and we subtract the uh um them from the indices we computed before, the last position ones.
00:36:57.760 --> 00:37:07.440
Uh we flip the arguments for the the commute, and then we have all the candidate numbers, and we take the greatest one and we can return.
00:37:07.599 --> 00:37:13.679
Uh not sure what this oh right now we're doing exactly the same thing on the second uh one because we do this in each, right?
00:37:13.760 --> 00:37:14.559
So we're stepping through it.
00:37:14.639 --> 00:37:32.079
I'm not going to actually go through the whole thing with with uh with all of them, but stepping in all the way, reverse, index of length, do the subtraction, the index selfie, and the subtract to get uh get all the candidates, and that's all negative ones.
00:37:32.159 --> 00:37:33.760
Okay, I'm just gonna step out of that.
00:37:33.920 --> 00:37:38.079
So I just think it was a great demonstration of using the inland tracing.
00:37:38.159 --> 00:37:38.960
Good call.
00:37:39.360 --> 00:37:41.119
All right, there's a bunch of things I want to see.
00:37:42.079 --> 00:37:44.639
Um how did this compare in length to the other solution?
00:37:45.039 --> 00:37:48.079
Can you put uh this original solution?
00:37:48.159 --> 00:37:49.679
It's I guess I stored as F.
00:37:49.840 --> 00:37:54.719
Now this new solution, and then also the indice were because then there was the one.
00:37:54.800 --> 00:37:55.840
Wow, actually, which one?
00:37:56.079 --> 00:38:00.880
There was the one just the one where we re-implemented key in terms of the outer product, right?
00:38:00.960 --> 00:38:03.039
There's no point that's what key is doing anyway.
00:38:03.280 --> 00:38:10.880
Well, so I want to I want to do the compare X on a like random string of 26 lowercase or like maybe a thousand lowercase.
00:38:11.519 --> 00:38:12.239
We can do that.
00:38:12.400 --> 00:38:15.599
Uh so this one, this one is F and this one is G.
00:38:15.840 --> 00:38:18.639
But we don't, I mean the outer product is going to be terrible.
00:38:18.800 --> 00:38:19.360
That's alright.
00:38:19.519 --> 00:38:20.400
We can do it if you want.
00:38:20.719 --> 00:38:21.039
That's okay.
00:38:21.199 --> 00:38:21.840
Should we do it?
00:38:22.079 --> 00:38:22.480
Nobody knows.
00:38:23.360 --> 00:38:24.880
I can't read which one do you want to do?
00:38:24.960 --> 00:38:26.800
The nested one or the the flat one?
00:38:27.119 --> 00:38:27.599
Let's do them both.
00:38:27.679 --> 00:38:28.320
Let's do them both.
00:38:28.400 --> 00:38:28.800
Let's have fun.
00:38:28.880 --> 00:38:30.000
Let's go wild, let's go crazy.
00:38:31.440 --> 00:38:37.039
And so while while Adam is putting this together, compare X, or um maybe there's there's like four different ways to spell it runtime, etc.
00:38:37.280 --> 00:38:37.440
etc.
00:38:37.760 --> 00:38:41.199
Is this beautiful thing that is in the dialogue APL REPL?
00:38:41.519 --> 00:38:45.199
Uh or I guess this isn't the REPL, this is the IDE or whatever you call it.
00:38:45.280 --> 00:38:57.920
But the you can basically inline profile things with like little Unicode boxes, and it's always a fun activity when you have multiple solutions to uh different problems uh to see which one is gonna be the best one.
00:38:58.159 --> 00:39:05.199
And I guess uh oh sorry, a couple uh comments send the role.
00:39:05.519 --> 00:39:11.519
I mean, yeah, it's a diadic iota is exactly oh, index in is what they call it in Wear, is that right?
00:39:11.760 --> 00:39:14.960
We call it index of, and then JavaScript has index of.
00:39:15.440 --> 00:39:18.000
Uh, but yes, that sounds like the same thing.
00:39:18.320 --> 00:39:18.960
Tubo.
00:39:19.440 --> 00:39:23.199
I want to add inline tracing to my own Lang, to my own language.
00:39:23.360 --> 00:39:26.719
How much would you say that the language design enables disables this?
00:39:26.880 --> 00:39:35.039
I mean it's just about whether you can pass things at runtime, isn't it?
00:39:35.280 --> 00:39:38.079
In order to have inline tracing.
00:39:38.960 --> 00:39:40.800
And also just uh FYI.
00:39:40.880 --> 00:39:45.679
Uh C4 Tubo is actually, I believe, I'm gonna kill myself if I get his name wrong.
00:39:45.920 --> 00:39:52.320
Chris from uh the Progue Lang Cast uh and Proguang Base YouTube channel and podcast.
00:39:52.559 --> 00:39:53.280
Oh, for real.
00:39:53.679 --> 00:39:55.599
Which we interviewed, right?
00:39:55.679 --> 00:39:56.960
On Eric Raycast?
00:39:57.519 --> 00:39:58.639
I'm almost positive we did.
00:39:58.800 --> 00:39:59.119
Christopher.
00:40:00.800 --> 00:40:01.360
Okay, got it.
00:40:01.599 --> 00:40:06.320
So you know you're getting old when you're like, uh, is my memory gonna work in this instance?
00:40:06.480 --> 00:40:13.199
Um and and the YouTube channel or YouTube channel, YouTube channel, podcast, all the same thing, I guess.
00:40:13.360 --> 00:40:17.440
They interviewed um Marshall one time, which was a great interview.
00:40:17.679 --> 00:40:23.039
Uh so, anyways, go check out the past uh Progline cast and ray cast episodes.
00:40:23.360 --> 00:40:29.440
Um and right here we got now uh Madeline Brigani, uh Tiny Apple.
00:40:29.519 --> 00:40:39.119
I was saying earlier in the podcast, I'm not sure if if you just joined live at this moment, Madeline, or you were listening at 2.0 XP to catch up.
00:40:39.360 --> 00:40:45.760
Um but I was I was wondering if Tiny Apple had Classify because I couldn't find it, but maybe it existed under a different name.
00:40:46.000 --> 00:40:52.320
Um but then also too, classify gives you that gives you the different indices, and actually, is that what you want?
00:40:52.480 --> 00:41:06.559
Because the different solutions we've looked at are you know you end up with the matrix or the the nested array, which then you can do your indices or your you know min-max forks on.
00:41:06.719 --> 00:41:17.519
But if you have classify where they're all jumbled together, can you actually do anything with that without you know having to split them up into the nested array that we got, anyways?
00:41:17.760 --> 00:41:20.639
Um so so I have a question for you, Connor.
00:41:20.800 --> 00:41:23.920
I can start doing the timings now, but the data is a bit interesting.
00:41:24.079 --> 00:41:27.599
If I just do random letters from the alphabet, we're going to have very few duplicates.
00:41:27.760 --> 00:41:29.760
That's also a question of how big should we make at least?
00:41:30.079 --> 00:41:32.960
Make it a thousand, uh make it just a thousand character string.
00:41:33.039 --> 00:41:33.840
That's all I want.
00:41:34.159 --> 00:41:36.000
One one thousand character string?
00:41:36.159 --> 00:41:37.360
Just one one thousand string.
00:41:38.239 --> 00:41:38.719
Yeah, yeah, yeah.
00:41:39.360 --> 00:41:39.519
Okay.
00:41:39.760 --> 00:41:42.639
And then we want to do uh F G H and I.
00:41:43.360 --> 00:41:44.159
Can we see the string?
00:41:44.239 --> 00:41:44.960
Let's see the string.
00:41:45.039 --> 00:41:45.920
Show us the string.
00:41:46.079 --> 00:41:47.440
Show me the string.
00:41:48.159 --> 00:41:49.360
You want me to scroll?
00:41:49.920 --> 00:41:50.719
Yeah, it's pretty good.
00:41:50.880 --> 00:41:53.679
I mean, and you know, everyone, everyone always says, Oh, blah, blah, blah.
00:41:53.760 --> 00:41:55.360
You gotta show all these.
00:41:55.519 --> 00:41:58.639
Have you got the the deaths out in a in a row?
00:41:58.960 --> 00:42:02.239
Um, I don't think I don't remember if it will show.
00:42:02.480 --> 00:42:03.599
Is that all varying?
00:42:04.000 --> 00:42:05.760
Never mind D there, we can erase that.
00:42:05.920 --> 00:42:06.320
I have no idea.
00:42:08.400 --> 00:42:11.599
And also the the shin might not be accurate.
00:42:12.000 --> 00:42:12.719
Good thing you didn't have any.
00:42:13.119 --> 00:42:13.280
It is.
00:42:13.360 --> 00:42:14.960
It's not the only time it fails.
00:42:15.119 --> 00:42:22.400
Yeah, the only time it fails is uh is if you've got things that have to be parenthesized, but it doesn't seem like it.
00:42:22.719 --> 00:42:25.440
But our intuition is h and this one.
00:42:26.159 --> 00:42:30.800
Wait, wait, before we do the intuition, so just just as a recap, we've got four functions here.
00:42:30.880 --> 00:42:32.480
They're called fgh and i.
00:42:32.559 --> 00:42:33.280
Not that that matters.
00:42:33.440 --> 00:42:37.440
F corresponds to the key solution that we showed right off the tap.
00:42:37.599 --> 00:42:40.000
Very beautiful, right off the tap, right off the top.
00:42:40.159 --> 00:42:41.679
That's the problem with live streaming, folks.
00:42:41.760 --> 00:42:43.599
Your speakos end up in the final cut.
00:42:43.760 --> 00:42:48.079
Then we've got G, which is the well, I guess we lost a selfie along the way.
00:42:48.159 --> 00:42:49.760
It was the selfie, selfie, selfie.
00:42:49.840 --> 00:42:52.559
You know, we're using the sigma combinator uh that we walked.
00:42:53.039 --> 00:42:55.199
We don't need it for this one because behind, right?
00:42:55.280 --> 00:42:57.280
So it really there should be one here, right?
00:42:57.440 --> 00:43:05.760
Because this it is essentially the self um index off with a with this behind text on.
00:43:06.000 --> 00:43:10.000
But the selfie is implied when it's monetic, so there's no need to do it.
00:43:10.079 --> 00:43:11.679
That's why I removed it here.
00:43:12.159 --> 00:43:12.960
Does that make any sense?
00:43:13.199 --> 00:43:18.480
Okay, because we can just if we don't have a left argument, we just use the right argument on the left, so that's it doesn't make a difference.
00:43:18.800 --> 00:43:37.840
But it was to show the relationship between formerly triple selfie, uh now double selfie, and then H and I are using the same uh min-max fork idiom, but one of them is using the uh unique outer product to get the indices corresponding to equal characters on each row.
00:43:37.920 --> 00:43:46.639
Uh, but then we learned the beautiful unique equals enclose fork, and the majority of those solutions are are the same.
00:43:46.880 --> 00:43:56.079
The interesting thing is after we uh profile this will be to is it gonna make a difference if we go in and uh replace some of the uh min's with firsts?
00:43:56.159 --> 00:43:59.039
But first, let's just uh compare is it running?
00:43:59.280 --> 00:43:59.840
Oh, look at that.
00:44:00.320 --> 00:44:02.000
Folks, we saw the intuition.
00:44:02.400 --> 00:44:16.320
Another thing I I changed a little bit uh uh analyzing the thing before, but uh I I ungulfed a little bit uh because of the it's more efficient to do the max first and then subtract one, then subtract one from a whole bunch of numbers and then do the max.
00:44:16.719 --> 00:44:19.039
So I changed that a little bit as you were talking.
00:44:19.280 --> 00:44:19.760
That's fine.
00:44:19.920 --> 00:44:22.079
But it doesn't make a huge difference.
00:44:22.639 --> 00:44:26.000
Well, so I mean the the listener, I mean we could we this doesn't looks wrong.
00:44:26.239 --> 00:44:30.000
We can still do the intuition, even though now we've run the expression.
00:44:30.320 --> 00:44:31.840
Um what were you gonna say, Rich?
00:44:32.320 --> 00:44:32.800
Just blind.
00:44:33.039 --> 00:44:35.280
I'm just I'm just covering up the in my own view.
00:44:35.360 --> 00:44:36.960
I'm just covering up for the audio listener.
00:44:37.039 --> 00:44:39.440
He's got a hand over the bottom half of his monitor.
00:44:39.760 --> 00:44:42.159
Oh, where the where results are.
00:44:42.320 --> 00:44:51.119
But it doesn't matter because it it sort of matches what I thought, except for Adam had already, if you were listening earlier, given the game away about F and G.
00:44:51.360 --> 00:44:55.920
The obvious big difference is between That's a lie, actually.
00:44:56.079 --> 00:44:57.840
I mean, it's slightly surprising.
00:44:58.000 --> 00:45:08.480
So H and I expect it to be a lot worse because they're both doing uh essentially out-of-products out-of-product comparisons between the entire individuals.
00:45:08.800 --> 00:45:11.760
Remember, it's not it's not uh n squared.
00:45:11.840 --> 00:45:13.199
We the unique is very small.
00:45:13.280 --> 00:45:16.800
Yes, there are a thousand elements, but we're only comparing them to 26 of them, right?
00:45:17.039 --> 00:45:18.480
So it doesn't matter as much.
00:45:18.559 --> 00:45:23.760
And the same thing goes for the difference between nested and flat in this case, very little, because there are only 26 elements.
00:45:25.599 --> 00:45:32.960
So it would be it would be much more interesting to have many many more different elements that it could be.
00:45:33.280 --> 00:45:34.159
I mean, we can do that.
00:45:34.639 --> 00:45:35.519
We can just do it with numbers.
00:45:36.000 --> 00:45:38.960
I think you want to add digits and uh uppercase random other.
00:45:39.599 --> 00:45:40.480
Just use numbers.
00:45:40.639 --> 00:45:42.239
Oh, yeah, just use numbers, yeah.
00:45:42.480 --> 00:45:43.679
Uh what am I doing here?
00:45:43.760 --> 00:45:55.360
Yeah, and then well, actually, first before you do uh a bunch of numbers, just do 0 to 25 or 1 to 26 to see if we get the same because you never know strings versus integer arrays.
00:45:56.000 --> 00:45:57.519
Yeah, no, we do know.
00:45:57.760 --> 00:46:04.480
We do if then yeah, because then the characters and and small numbers are stored identically internally.
00:46:04.639 --> 00:46:05.519
So yes, we do know.
00:46:05.920 --> 00:46:08.000
Show me and I will believe you.
00:46:08.239 --> 00:46:12.719
I I've I I've as a former C compiler compiler.
00:46:13.039 --> 00:46:15.199
Okay, so here instead of indexing.
00:46:16.559 --> 00:46:20.559
I trust nothing uh performance result-wise until I see it.
00:46:20.639 --> 00:46:37.119
Uh, because there's so many times where I've been like, well, obviously it does this, and uh you know compiling is so we can do this and and for uh so we I'm not sure if we actually fully it's like one bit difference in the internal representation between the numbers and the thing.
00:46:37.440 --> 00:46:39.199
Whoa! Look at that.
00:46:39.440 --> 00:46:40.559
Who was correct?
00:46:40.800 --> 00:46:41.119
Me.
00:46:41.360 --> 00:46:41.920
One second.
00:46:42.000 --> 00:46:43.440
No, no, no, did I make a mistake here?
00:46:43.679 --> 00:46:43.920
Maybe.
00:46:44.079 --> 00:46:52.480
So wait, and also why Adam is potentially fixing this, in case it wasn't clear for the audio listener, because we did some intuition, but then I'm not sure if we fully recapped.
00:46:52.719 --> 00:47:04.159
For the character string of uppercase letters, the slowest by a factor of two compared to the next uh actually, I guess we should do it as compared to the fastest.
00:47:04.320 --> 00:47:07.519
It looks like it's about five times, six, seven times slower.
00:47:07.599 --> 00:47:09.440
So it's the slowest one was the key.
00:47:09.599 --> 00:47:24.800
Then the outer products, um, the outer product and the uh kind of idiom that is similar to that, the unique equals enclose, uh, are very close, but the outer product is slightly faster, and that's about half the speed of the key.
00:47:24.880 --> 00:47:29.360
And then the fastest by far was the double selfie using the dyadic iotas.
00:47:29.519 --> 00:47:33.119
And now Adam is trying to fix the integer to match.
00:47:34.079 --> 00:47:40.719
Is that function that that uh Rich was warning about uh the diffs that this removes too many parentheses?
00:47:40.880 --> 00:47:44.559
It effectively removes too many, despite my thinking it was good enough.
00:47:44.719 --> 00:47:49.119
And we can see here that if you compare these two, I'll run this one again for the so yeah.
00:47:49.199 --> 00:47:57.199
This one uh I guess the noise between the outer product and the unique closed these these two have to compose compare.
00:47:57.280 --> 00:47:59.440
This is the numeric one, this is the text one, right?
00:47:59.519 --> 00:48:00.880
They are virtually identical.
00:48:01.119 --> 00:48:01.519
Okay, yeah.
00:48:01.599 --> 00:48:18.639
So that's just to say that the noise between the the last two solutions, H and I, that were the outer product uh unique and then you the unique equal enclosed, those are effectively you can count as the same because there's between the solutions one time, one was faster, the other one time, the other was slightly faster, and one of them they look identical.
00:48:18.719 --> 00:48:28.239
Uh so the point being is key is by far the slowest by like a factor of six, and the h and i, the outer product, and the equivalent uh you know, fork unique.
00:48:28.559 --> 00:48:29.599
What do we call that in idiom?
00:48:29.679 --> 00:48:32.079
We I guess we just call it unique equal enclose.
00:48:32.400 --> 00:48:39.440
Those are about three times as slow, and then the fastest by far is the diadic iota, which why is key so valuable?
00:48:41.039 --> 00:48:46.079
Because key in this case, we're giving it a uh oh a custom operand.
00:48:46.400 --> 00:48:47.360
Oh, that's a good point.
00:48:47.519 --> 00:48:54.000
If you rewrote this so that instead of a custom operand to key, you just did enclose omega.
00:48:54.559 --> 00:49:06.559
So you basically just rephrase key to become what uh it seems uh in BQN is in uh group, sorry, yeah, just group, group indices slash group.
00:49:06.800 --> 00:49:11.840
So we want to do and it's been argued that this is a way to do it.
00:49:11.920 --> 00:49:26.320
So like a little under the covers here is the the sort of rationale behind some operators, uh at least in dialogue is what you can do is because you know you can inspect the operands at runtime to see what the functions are actually spelled like.
00:49:26.559 --> 00:49:33.599
And by doing that, you can take some of those operands that you expect users to use and optimize them as special cases, right?
00:49:33.679 --> 00:49:35.920
And that only really works with operators.
00:49:36.400 --> 00:50:15.119
Um but of course it means you have to spell things in a particular way, unless you have something that's something like just in time compilation or something that can track, you know, there's this there's this idea that floats around called thunks, which is uh keeping track of things that have not yet been computed or that you intend to compute, and then passing that information along to future functions, and then they can look and say, Oh, you said you were going to compute this, but actually, since I'm gonna compute this other thing and I know what you were gonna give me, we can actually do this other thing that's faster instead of it uh materializing intermediate values.
00:50:15.440 --> 00:50:24.079
Anyway, that's the rationale, but in practice, you know, it's hard to anticipate, it's hard to uh produce all of those special cases.
00:50:24.159 --> 00:50:31.599
But one of the special cases for key, for example, in stencil is like this too, is just group the stuff and give it back to me as a nested array.
00:50:31.840 --> 00:50:42.400
And that is so fast with the special case that sometimes it's a lot faster to do the grouping and then apply your operand function with each instead of applying the operand function directly.
00:50:43.440 --> 00:50:45.440
So now I don't know this must have been a dialogue.
00:50:46.400 --> 00:50:50.320
Something yeah, something happened over here that uh that made it run slow.
00:50:50.639 --> 00:50:51.280
Here it is again.
00:50:51.360 --> 00:50:55.599
We can recognize this pattern from before, but now the key one is much faster.
00:50:55.679 --> 00:50:57.360
It's faster than the outer product ones.
00:50:57.679 --> 00:50:59.519
Right, which is what I would have expected.
00:50:59.760 --> 00:51:02.079
Yeah, so the only thing I did was you made here.
00:51:02.400 --> 00:51:07.360
So if you compare F, uh that we have uh next to each other.
00:51:07.679 --> 00:51:09.840
Yeah, I'm going to take the carry them down there.
00:51:10.079 --> 00:51:10.320
Cool.
00:51:10.800 --> 00:51:12.639
F there and F2 there.
00:51:12.880 --> 00:51:17.440
So firstly I switched to implicit, uh to explicit because too many.
00:51:18.960 --> 00:51:40.079
But uh basically what I did here was instead of feeding this giant custom operand to key, I'm just using this operand, which would be slow because it's the it forces nested arrays, but in fact, it is a a spelling that key recognizes, and instead of going through all these motions, it knows exactly what to do.
00:51:40.400 --> 00:51:43.360
Exactly, it's internally optimized, and so we go for go from there.
00:51:43.599 --> 00:51:50.880
Another thing that's interesting to look at is the instead of max, we want to do first and last, so we can try that as well.
00:51:51.280 --> 00:51:56.800
Yeah, if you do you could do right tack, you just switch something for the taxation from right and left and left.
00:51:57.039 --> 00:51:57.599
What do we call it?
00:51:59.039 --> 00:52:01.119
G G H H I I or whatever.
00:52:01.360 --> 00:52:04.079
I guess uh it doesn't matter so much.
00:52:04.239 --> 00:52:08.159
We can just call them uh I just have to find them uh here.
00:52:08.400 --> 00:52:11.440
This is the F1, right?
00:52:11.760 --> 00:52:14.320
So this is F A.
00:52:15.039 --> 00:52:19.679
We wanna replace uh the last and the first.
00:52:19.920 --> 00:52:20.800
Okay, right like this.
00:52:20.880 --> 00:52:22.800
It doesn't matter if it's how we start.
00:52:24.000 --> 00:52:29.119
And we want to do G doesn't matter, it's the same thing, it's obviously going to be fast still.
00:52:29.519 --> 00:52:36.559
And I here we wanna do the last one and the last one and the first one and the first one.
00:52:37.280 --> 00:52:40.639
F G H and I like that.
00:52:40.800 --> 00:52:41.519
And then we want to do that.
00:52:41.679 --> 00:52:42.960
Do you expect these to be faster?
00:52:43.199 --> 00:52:44.559
Yeah, a little bit at least.
00:52:44.719 --> 00:52:50.559
I'm not sure if it matters so much in the grand scheme of things, but uh but we can try it.
00:52:50.880 --> 00:52:56.079
See, this is where this is where, you know, I have uh what do you call it?
00:52:56.239 --> 00:53:01.280
I guess I don't have a name for it, but like there's these optimizations that you can make.
00:53:01.440 --> 00:53:19.840
Well, I mean I guess I guess this stuff is built into interpreters like dialogue APL and BQN, but like the you know, I I've always said if you keep track of the sortedness of stuff, you know, like uh you can make optimizations, like if you ever call min or max on a sorted sequence, it'll just dispatch to like the first or last.
00:53:20.000 --> 00:53:22.079
But then people say, Oh, like when would you ever do that?
00:53:22.239 --> 00:53:36.800
This is an example of where you know having those kinds of because I know that like I'm I'm not sure if dialogue tracks it, but I know Marshall said that in BQN he has a bunch of these like metadata flags that track the sortedness and whether it's Boolean, etc.
00:53:36.960 --> 00:53:38.639
And then they dispatch to different algorithms.
00:53:38.800 --> 00:53:39.760
This would be a perfect example.
00:53:39.840 --> 00:53:49.599
Like if we saw no perf difference, you might be able to assume that uh because the uh indices of the result of these operations are always going to be sorted, if you're able to track that.
00:53:49.920 --> 00:53:53.519
It would um and as we're I mean, uh Madeline's been posting in the chat.
00:53:53.679 --> 00:53:54.320
Oh, here we go.
00:53:54.400 --> 00:53:54.639
Never mind.
00:53:54.719 --> 00:53:56.400
We'll talk about the tiny APL.
00:53:56.480 --> 00:53:58.559
Uh yeah, we'll come I'm gonna look at this.
00:53:59.119 --> 00:54:00.239
Should I have sorted these?
00:54:00.320 --> 00:54:05.199
Uh yeah, just can you do the defs under underneath this and then we can show it all on one screen?
00:54:05.519 --> 00:54:15.920
It's sort of I can, but it remember the def doesn't show it really correctly, but it gives an idea what's what is supposed to happen because the it's missing parentheses around a bunch of them, but it doesn't matter so much.
00:54:16.239 --> 00:54:17.599
What's happened that's interesting?
00:54:17.760 --> 00:54:18.480
Oh yeah, okay.
00:54:18.639 --> 00:54:24.239
We're trying to do the right we really want to compare F with FA, so that's nine percent faster there.
00:54:24.480 --> 00:54:29.440
Wanna comp F2 uh it didn't mat F2 with F.
00:54:29.599 --> 00:54:33.280
Oh, yeah, but mean optimization is no no, I messed it up.
00:54:33.360 --> 00:54:34.880
I'll I'll redefine that.
00:54:34.960 --> 00:54:35.599
I messed it up.
00:54:35.760 --> 00:54:39.039
That's F2, and we want to do an F2A is this one.
00:54:39.280 --> 00:54:46.079
I really should just compare two that are the same with rights and left instead of max and min's instead of trying to put them all on one.
00:54:46.559 --> 00:54:52.320
F2A, but what I was thinking as we should do is just sort these instead of makes it easier to do it.
00:54:52.480 --> 00:54:53.599
So how did we do it?
00:54:53.760 --> 00:54:55.039
A top behind.
00:54:55.519 --> 00:55:10.559
For the audio listener, the last of last index of double selfie solution is still the fastest, but looks there looks to be small improvements to uh replacing the min reduction with a first.
00:55:11.039 --> 00:55:19.360
And I guess technically I was gonna say, have you did you replace replace the max reduction with a right write reduce, which is optimal.
00:55:19.840 --> 00:55:20.400
We can't do that.
00:55:20.480 --> 00:55:23.280
We can't do that here because you don't know which one is going to be the largest one.
00:55:23.360 --> 00:55:24.880
There we actually need the max.
00:55:25.440 --> 00:55:31.519
It's only the only the ones to find the indices, the first and last index, those are the ones that are that we can replace.
00:55:31.760 --> 00:55:33.199
Why do I have two F2s?
00:55:33.440 --> 00:55:34.000
Doesn't matter.
00:55:34.159 --> 00:55:39.119
But this shows us something about uh it shows something about the accuracy of the results.
00:55:41.440 --> 00:55:42.719
Because you wrote F2 twice.
00:55:42.960 --> 00:55:44.559
Yeah, I wrote it twice for mistake.
00:55:44.639 --> 00:55:48.480
It doesn't matter, but that knows that we can we can't we actually everything is like plus minus five percent anyway.
00:55:49.039 --> 00:55:54.880
So f2a, we can see that it it didn't really make a difference from F2 to F2A.
00:55:55.519 --> 00:55:59.760
Um F A is significantly f faster than F.
00:56:00.320 --> 00:56:04.159
Uh G, it doesn't matter because it doesn't use that technique.
00:56:04.320 --> 00:56:05.679
You can see A, you can see these.
00:56:05.760 --> 00:56:08.000
The H A is slightly faster than H.
00:56:08.480 --> 00:56:11.119
IA is slightly faster than than I.
00:56:11.360 --> 00:56:12.559
So yeah, it does make a difference.
00:56:12.880 --> 00:56:15.920
F A versus F where it's the biggest difference.
00:56:16.079 --> 00:56:21.039
That's probably where it's that's probably no yeah.
00:56:21.199 --> 00:56:24.880
It's no, it's the same amount, it's the same sort of percentage-wise difference, isn't it?
00:56:25.039 --> 00:56:26.480
Out of the whole total work.
00:56:26.880 --> 00:56:36.639
But they're direct uh directly comparable because they're the literally the same except ones using rights and left, ones using max and mints.
00:56:36.960 --> 00:56:55.280
And so there's another thing it's interesting, yeah, why because the number of times it's running should be this the number of times it's running should be it's just the number of unique elements for both the key.
00:56:56.400 --> 00:56:58.559
The way key is slowing everything down, yeah.
00:56:58.639 --> 00:56:59.360
I don't know.
00:56:59.599 --> 00:57:02.079
Yeah, I'm not sure why there's it's the same relative difference.
00:57:02.239 --> 00:57:05.599
Everything maybe key is just slows everything down inside itself.
00:57:05.840 --> 00:57:10.480
So easy so the relative difference between max and mean is just gets exaggerated in there.
00:57:10.559 --> 00:57:10.800
I don't know.
00:57:11.199 --> 00:57:13.440
Maybe every time I don't know.
00:57:14.079 --> 00:57:14.880
Oh, here's another thing.
00:57:14.960 --> 00:57:16.000
No, and here's another thing.
00:57:16.239 --> 00:57:20.480
Key might reparse its operand every time around the loop.
00:57:20.960 --> 00:57:26.800
But right tech reduction and left tech reduction are uh are tokenized as such.
00:57:26.960 --> 00:57:28.800
They're two cliff tokens actually.
00:57:29.039 --> 00:57:29.519
Oh right.
00:57:29.760 --> 00:57:33.119
So it might it doesn't need to reparse them, it's not actually a reduction at all.
00:57:33.599 --> 00:57:35.360
It doesn't go through reduction code at all.
00:57:35.440 --> 00:57:43.840
It immediately goes to the last last major cell function and the and the first major cell function, which are primitives in the interpreter, but not in the language.
00:57:45.280 --> 00:57:47.039
So yeah, okay.
00:57:47.440 --> 00:57:52.800
But as you can also see, it doesn't matter if we're using numbers or characters.
00:57:53.280 --> 00:57:57.599
If we if you compare those those two here, it's exactly the same time.
00:57:58.000 --> 00:58:02.159
Do we wanna you at one point we were gonna change it to have way more?
00:58:02.880 --> 00:58:03.920
Way more possibilities, yeah.
00:58:04.079 --> 00:58:05.119
So now we can do that, right?
00:58:05.199 --> 00:58:07.280
If we go up to well, we could just do it here.
00:58:07.360 --> 00:58:14.480
So if you do uh big n is a thousand, reshape one thousand instead.
00:58:14.639 --> 00:58:14.880
Right?
00:58:15.119 --> 00:58:18.400
So now there's there are much smaller chance of there being duplicates.
00:58:18.480 --> 00:58:20.000
There will be some big duplicates, right?
00:58:20.159 --> 00:58:22.800
So if you do G is the fastest one, right?
00:58:23.599 --> 00:58:26.639
So it's a very there are duplicates and they're far away from each other.
00:58:26.960 --> 00:58:28.719
Birthday problems abound here.
00:58:29.039 --> 00:58:31.599
Uh wanna run the unique on this as well.
00:58:31.920 --> 00:58:36.559
No, it doesn't matter because we need what do you do we want to run all of it on this big one as well?
00:58:36.800 --> 00:58:37.440
I guess so.
00:58:37.840 --> 00:58:50.320
Uh I guess I was thinking more just comparing like key and outer product, and so like just G I H or whatever we can pass it afterwards.
00:58:50.880 --> 00:58:54.880
Uh Madeline's index of solution by far the slowest.
00:58:55.360 --> 00:58:55.920
We'll show this.
00:58:56.000 --> 00:59:01.039
I mean, you guys aren't gonna see this, uh, but I've I've been compiling Madeline's solutions.
00:59:01.119 --> 00:59:04.480
I mean, if you look at the YouTube stream, it'll show up in a couple seconds for you.
00:59:04.639 --> 00:59:05.519
Uh or now.
00:59:05.920 --> 00:59:07.679
But Madeline has a couple different solutions.
00:59:07.760 --> 00:59:08.639
We'll look at this in a second.
00:59:08.719 --> 00:59:12.800
She's mentioned that her index of is the slowest, but that's just an implementation thing.
00:59:12.960 --> 00:59:15.039
But anyways, the solutions are back, folks.
00:59:15.199 --> 00:59:18.159
And now there's a big difference between some of them.
00:59:18.320 --> 00:59:22.639
No, because they're in different order as well, so it can't really start to compare.
00:59:22.880 --> 00:59:24.639
Uh so now there are many more.
00:59:24.800 --> 00:59:26.400
We can count the unique, right?
00:59:26.639 --> 00:59:28.559
Telly unique N.
00:59:28.960 --> 00:59:31.039
So there's six four unique values.
00:59:31.360 --> 00:59:34.719
That means there are very few, very few duplicates, right?
00:59:34.960 --> 00:59:42.320
And so just yeah, once again, because we've been uh you know, we're watching this on screen, so we don't have as much confusion as as I'm sure the audio listener does.
00:59:42.639 --> 00:59:47.519
Definitely have to go watch this on YouTube because honestly, this is uh this is a valuable educational material, folks.
00:59:47.599 --> 00:59:51.840
I'm learning a ton, and it's probably way easier to follow along if you're watching the video.
00:59:52.000 --> 01:00:08.639
However, if you really do like the podcast format, what we're doing now is we switched from our 26 uh possible characters in a lowercase or uppercase string to now uh an integer sequence of up to um anywhere to a maximum of a thousand possible values.
01:00:08.800 --> 01:00:19.280
And so in this test sequence, we have a thousand characters, and we just did a tally of the unique, and so there are six hundred and thirty-four, much higher than the possible 26 unique characters.
01:00:19.440 --> 01:00:26.559
And now we are going to see the impact on the profiling of the same solutions that we just looked at for the character string.
01:00:26.960 --> 01:00:30.159
See, my guess is what is I was gonna say he's looking for the maximum.
01:00:30.239 --> 01:00:34.559
I was gonna say it's either a thousand or he's looking at what's the most occurring thing.
01:00:35.039 --> 01:00:38.079
So the one that has the most duplicates has five duplicates, right?
01:00:38.400 --> 01:00:39.119
Interesting.
01:00:39.440 --> 01:00:44.880
So so this is a whole different it's a different set that we had before, and they're they're two-byte integers.
01:00:45.039 --> 01:00:50.800
Not that it matters a whole lot, but yeah, you can go looking for 64-bit floats if you want.
01:00:52.480 --> 01:01:01.280
So the trend is the same, it's just more exaggerated, where we we have a solution that was six to seven times faster, the index of compared to the slowest one.
01:01:02.320 --> 01:01:06.320
F A and F are the ones that are really slow, the key solutions there.
01:01:06.480 --> 01:01:16.639
Uh the F2, where we broke out uh the post-processing of the of the result from key, uh, is it takes half the time basically as before?
01:01:16.800 --> 01:01:19.599
It helps a little bit to do first and last, as before.
01:01:19.920 --> 01:01:22.400
Here, the this is plus minus five percent.
01:01:22.480 --> 01:01:28.079
So so by now everything is drowning out, and we yes, this is five percent faster with the first last.
01:01:28.320 --> 01:01:33.440
The fact that this one is slower than its first last one, I I wouldn't take that at face value.
01:01:33.519 --> 01:01:38.719
I would re-measure that if it was uh because I don't believe it.
01:01:38.960 --> 01:01:40.800
I mean C MPX, we just try it.
01:01:40.960 --> 01:01:46.639
C MPX, uh H big N and uh H A big N.
01:01:47.039 --> 01:01:52.800
I think it's just noise and uh and drowning because of the other things that are going on.
01:01:53.119 --> 01:01:53.679
There you go.
01:01:53.760 --> 01:01:55.519
Yeah, that's expected.
01:01:56.000 --> 01:01:57.679
So yeah, first last is better.
01:01:57.840 --> 01:02:00.079
This, I mean, I also get something out of this.
01:02:00.239 --> 01:02:06.239
This we this is helps me in in bolstering my view that we should add the last primitive.
01:02:06.480 --> 01:02:09.280
I think that would be like even conceptually nice things to have.
01:02:09.360 --> 01:02:11.760
So we could do like last minus first.
01:02:11.920 --> 01:02:12.480
That's one thing.
01:02:12.719 --> 01:02:18.559
Oh, because uh because people don't necessarily reach for the right tack reduce idiom.
01:02:18.639 --> 01:02:22.960
It's more of yeah, I think that's it's more obscure, right?
01:02:23.039 --> 01:02:24.000
And it's not the same either.
01:02:24.159 --> 01:02:27.199
Right tech reduces is last major cell.
01:02:27.280 --> 01:02:29.920
This would be last element in rebel order.
01:02:30.000 --> 01:02:30.719
It's not the same.
01:02:30.880 --> 01:02:38.079
It's last like it's not even last major last column or well, it's it's last really should be like this.
01:02:38.159 --> 01:02:39.360
This is last major cell.
01:02:39.599 --> 01:02:41.840
Last yeah, oh yeah, that's true.
01:02:41.920 --> 01:02:43.920
Sorry, yeah, it is last major cell there.
01:02:44.079 --> 01:02:44.400
Right?
01:02:44.559 --> 01:02:46.239
So how you want to write it, yeah.
01:02:46.559 --> 01:02:48.239
And this is first major cell.
01:02:48.559 --> 01:02:53.360
All right, and then we've got first column if you're right tag slash bar, left tack slash bar.
01:02:54.000 --> 01:02:56.559
And yes, sorry, I should speak this up so the listeners.
01:02:56.800 --> 01:03:06.000
And and yeah, and and left tech reduce, right tech normal, like last axis reduces, those are left and right columns in a matrix and not very meaningful in the higher dimensional array.
01:03:06.239 --> 01:03:10.239
And then we've got a first function that this as a disclosure one, right?
01:03:10.320 --> 01:03:13.599
It picks out the first element or coerces one out.
01:03:13.760 --> 01:03:20.400
That's another difference that you you can't do last element with a right tech reduction over an empty list.
01:03:20.719 --> 01:03:26.960
But you can ask, or you can't do the first one either, but you can get the first element which coerces out a prototype.
01:03:27.360 --> 01:03:28.559
So, how do you get the last one?
01:03:28.639 --> 01:03:38.480
So there actually is an a built-in idiom thing where if you it this tokenizes, but there's not always the combination and ends up nicely, you might need like in the top.
01:03:38.639 --> 01:03:45.519
So there's a a first of the reverse, which is also seem to be slow, but isn't if you're lucky.
01:03:45.920 --> 01:03:53.360
I think it would be nice to have a reverse, uh a last glyph, is something quite often, especially in this case, it was actually first and last.
01:03:53.519 --> 01:04:02.480
But I find that it's very often I want to operate on something that has exactly two elements, and I want to be able to address the left element and the right element, and that's also first and last.
01:04:02.800 --> 01:04:04.480
Um, so that's something I want.
01:04:04.559 --> 01:04:06.559
So that's one one thing that this has done for me.
01:04:06.719 --> 01:04:24.320
Another thing has done for me is this exact thing of key with the enclosed right argument, that means key that just works under on the indices and returns a list of indices, list of lists of indices, um, is an extension to key that that's key with vocabulary essentially.
01:04:25.920 --> 01:04:27.840
This is just a group by function.
01:04:28.159 --> 01:04:32.880
Sure, but key with vocabulary does accept that the my proposal for key with vocabulary.
01:04:33.280 --> 01:04:36.079
Oh, would do that as a monastery as well, right?
01:04:36.320 --> 01:04:36.719
Yeah.
01:04:37.119 --> 01:04:42.639
If no, you have to provide the vocabulary as yeah, but we in this case with the alphabet, we know what the vocabulary is.
01:04:43.039 --> 01:04:43.280
Sorry.
01:04:43.519 --> 01:04:43.760
Yeah.
01:04:44.000 --> 01:04:47.679
So if it al if sorry, so if we were to write how would you spell it?
01:04:47.760 --> 01:05:05.039
So right now it's doing open curly brace enclose omega right curly brace key, and that is the group by function returns a nested list, nested vector of your uh uh so with the vocabulary, it wouldn't yeah.
01:05:05.199 --> 01:05:09.039
Um what's called uh let's see if I can find those.
01:05:09.599 --> 01:05:10.800
Adam has a proposal.
01:05:10.960 --> 01:05:38.320
Well the key in dialogue at least, the one of the bugbears is that if you want to uh sort your results or if you want to have sort of um fill you want to have results that include uh zeros, for example, where an element an element type that you know about doesn't occur, yeah.
01:05:38.559 --> 01:05:54.320
Then you have to prov you have to prepend basically your onto your argument and sometimes onto your set of keys, a vocabulary, a set of you have to basically prepend with the unique elements that you're interested in in the order that you're interested in.
01:05:54.639 --> 01:05:59.519
Yeah, so if we do this, right, if you let's say we want to find letter frequencies, so here we can.
01:06:02.320 --> 01:06:08.239
So this this is not a useful result because we don't know what what they are, right?
01:06:08.480 --> 01:06:18.639
And even if we even if we do put in the left argument here, so we do like this, this doesn't give us the zero for all the letters that are missing, right?
01:06:18.880 --> 01:06:20.000
How many X's are there?
01:06:20.159 --> 01:06:20.639
We don't know.
01:06:20.880 --> 01:06:21.519
It doesn't say.
01:06:21.679 --> 01:06:23.119
We have to fill that in later.
01:06:23.360 --> 01:06:25.280
So that's uh that's a bit annoying.
01:06:25.440 --> 01:06:30.880
So the key with vocabulary, which of course it can do the same thing, but we can basically tell it.
01:06:31.039 --> 01:06:39.519
So if you go back to just this here, we tell it instead that the vocabulary is the alphabet.
01:06:39.760 --> 01:06:42.960
And now it gives us even the letters that are missing.
01:06:43.199 --> 01:06:46.000
And then we can go and and check for each one.
01:06:46.320 --> 01:06:56.239
So this is again this pattern of wanting actually wanting this and actually wanting for all of them, in our case it wouldn't it wouldn't matter because first and last it wouldn't have made a difference anyway.
01:06:56.480 --> 01:07:02.719
Oh we explicitly only care about the argument for the for the per weekly challenge.
01:07:02.960 --> 01:07:05.039
Sure, but but here's another problem then.
01:07:05.199 --> 01:07:10.000
So let's let's just say that we did have key with the vocabulary, and now we want to do the first and last.
01:07:10.639 --> 01:07:24.639
So we get we get these lists here, and one of the lists is uh the empty vector, and now we want to do the uh well, the last minus the first, and we get an error, like we said before, because they're not the same.
01:07:24.960 --> 01:07:34.800
Really, what we what we want to do is we want to get the first, which we can get, which is zero, and the last, which is zero, and subtract them from each other, which is zero, right?
01:07:34.960 --> 01:07:38.000
And then it's all good, but we're missing the last primitive.
01:07:39.039 --> 01:07:42.400
So um let's get that.
01:07:43.679 --> 01:07:46.960
Also, too, I I totally forgot that uh what was it?
01:07:47.199 --> 01:07:48.239
Let's go get the username.
01:07:48.320 --> 01:07:50.880
Was it uh D Zen Neroli?
01:07:51.199 --> 01:07:57.360
We said that we would mention the uh week if if uh they found the number, and they did.
01:07:57.519 --> 01:07:59.760
And then we were steeped in the solution.
01:07:59.840 --> 01:08:00.719
It would did we say it?
01:08:00.800 --> 01:08:01.760
Was it 372?
01:08:01.840 --> 01:08:02.719
Or did you say it, Rich?
01:08:03.199 --> 01:08:05.760
It is 372, whether or not it was said.
01:08:06.000 --> 01:08:06.480
Oh, yeah, yeah.
01:08:06.719 --> 01:08:07.440
So we might have failed.
01:08:07.519 --> 01:08:08.000
What are we at?
01:08:08.079 --> 01:08:10.239
We're at the like you know uh 80-minute mark.
01:08:10.400 --> 01:08:12.559
And so we might have failed to mention that this is.
01:08:12.639 --> 01:08:14.159
I mean, does it actually matter?
01:08:14.320 --> 01:08:21.439
Not really, but uh for folks in the future um that are 80 minutes into this, being like, wow, where's the problem statement?
01:08:21.600 --> 01:08:25.840
And potentially too, this is kind of a classic uh interview e.
01:08:25.920 --> 01:08:32.720
I bet if I search this uh on Google, it also corresponds to like a leak code problem.
01:08:32.880 --> 01:08:34.960
Um anyways, back to you, Adam.
01:08:35.119 --> 01:08:35.359
Sorry.
01:08:35.520 --> 01:08:36.079
No, that's fine.
01:08:36.159 --> 01:08:45.840
I'm just I'm just showing how the key that always does uses that function but with vocabulary, it would still work because we'd get uh we'd get these distances being zero here.
01:08:46.159 --> 01:08:52.399
Yeah, but then you get a bunch of negative ones for things you don't care about or it doesn't matter because we want the maximum, right?
01:08:52.640 --> 01:08:53.600
Oh, you're right, yeah.
01:08:53.840 --> 01:08:57.600
And then and then subtract one, so sure it actually doesn't matter.
01:08:57.840 --> 01:08:58.319
Well.
01:08:58.640 --> 01:09:07.760
And it is indeed lead code problem 1624 with a much more specific name of largest substring between two equal characters.
01:09:08.159 --> 01:09:11.039
So I was thinking about this because what am I going to call this episode?
01:09:11.199 --> 01:09:16.560
Should I call this episode like key versus index of versus outer product?
01:09:16.800 --> 01:09:20.000
Because honestly, that is what's more I think important here.
01:09:20.079 --> 01:09:41.039
Is like we're discussing the trade-offs between primitives, how it affects your solution, uh, or do I call it like PwC, you know, 372 part two, which means absolutely nothing to like people of the interwebs, but like will mean like when I think about this uh episode in the past, like I will think about, oh yeah, that's the time we solved that pro-weekly challenge problem.
01:09:41.359 --> 01:09:44.479
Like, so uh you know, it's uh what should we actually call this?
01:09:44.560 --> 01:09:46.720
Because currently this episode does not have a title.
01:09:46.800 --> 01:09:52.960
Uh the you know, repeat listeners will know that uh we just called it 125 and we're gonna we're gonna add a title later.
01:09:53.039 --> 01:09:56.000
So yeah, it was a big problem for us at dialogue, by the way.
01:09:56.159 --> 01:10:04.800
And we our website people were unable to put this episode on our calendar of upcoming events because there's nothing to put in the title.
01:10:05.199 --> 01:10:07.600
See they can't just put array cast 125.
01:10:07.680 --> 01:10:09.439
That's not uh that's not enough information.
01:10:09.600 --> 01:10:10.640
Uh I guess not.
01:10:10.720 --> 01:10:12.079
That's a value or something.
01:10:12.399 --> 01:10:14.399
Choose in advance when you're not interested.
01:10:14.560 --> 01:10:18.079
Um so so yeah, I think I think this is pretty neat.
01:10:18.239 --> 01:10:22.479
Um I I I would think that key with vocabulary can be made faster.
01:10:22.640 --> 01:10:37.520
My model isn't intended to be fast in any way, but I would think it could be faster because key, when it starts working, normal key, it doesn't know like uh like for with this function of in-close omega, it doesn't know how many unique elements there are.
01:10:37.680 --> 01:10:37.920
Right?
01:10:38.079 --> 01:10:55.680
It will have to traverse first and find out what are all the unique elements, or as it goes along, it will have to make more and more uh result collection pockets where it's going to keep adding in in indices, but it doesn't know how many they're going to be, so it doesn't know how much space to reserve for each one of them either.
01:10:55.920 --> 01:11:01.520
I would think that it would be advantageous for key to know in advance that I'm only looking for these 26 letters.
01:11:01.600 --> 01:11:05.760
That means if I find any elements that are not among these 26 letters, I'm not going to consider them.
01:11:06.159 --> 01:11:07.119
Just going to skip them.
01:11:07.279 --> 01:11:12.960
So it knows it can start building up slots of uh 26 slots.
01:11:14.000 --> 01:11:18.479
It doesn't know how many it's gonna find, so I don't think that's true, but now it has some bound on them.
01:11:18.560 --> 01:11:25.920
It knows they're going to be a great many duplicates, so it could at least on average, or some kind of uh I don't know, geometric average thing.
01:11:26.000 --> 01:11:39.359
You could it could start off by reserving like at uh twice the or something like that, the the total number of elements divided by the number of elements we're looking for, something like because it knows it's going to fill at least quite a few of them.
01:11:39.439 --> 01:11:40.800
Then it can always compact it later.
01:11:40.880 --> 01:11:43.039
Something like I mean I don't know, I'm not a supercommer.
01:11:43.199 --> 01:11:54.560
I think I think some things could there's some tricks they could do sort of uh guess to best guess and compact things later rather than having to be completely in line to what's going to be later.
01:11:54.960 --> 01:11:55.840
Indeed.
01:11:56.239 --> 01:12:00.800
Um and you could um if this works in the model actually.
01:12:02.479 --> 01:12:06.560
Connor, as we surpassed minute 83 or so.
01:12:06.800 --> 01:12:09.439
You had the collection of uh Madeline's tiny.
01:12:09.760 --> 01:12:12.239
Yeah, should we show we should we show those uh the solutions?
01:12:12.640 --> 01:12:13.600
You want me to stop sharing?
01:12:13.760 --> 01:12:14.239
You can show those?
01:12:14.640 --> 01:12:19.840
Yeah, I'll uh I'll steal how do we do the entire screen Google NeWorks.
01:12:20.000 --> 01:12:26.000
It's a little behind the scenes for the YouTube people because they can see for like three seconds my uh monitor, my multiple monitors.
01:12:26.159 --> 01:12:27.840
Uh show my screen, anyways.
01:12:28.079 --> 01:12:28.640
There we go.
01:12:28.800 --> 01:12:33.920
And so now I'm gonna be staring at my top monitor, even though you know You want to click that button.
01:12:34.159 --> 01:12:34.640
What button?
01:12:34.800 --> 01:12:35.439
Oh yeah, yeah, yeah.
01:12:36.079 --> 01:12:38.640
So you're behind now, but uh if you it depends on whether you're watching the YouTube.
01:12:39.199 --> 01:12:40.640
So what page is this as well?
01:12:40.960 --> 01:12:42.159
Is this the array box?
01:12:42.560 --> 01:12:44.239
My uh my array box is array.
01:12:44.479 --> 01:12:46.079
Is this the array box that's up?
01:12:46.319 --> 01:12:47.840
Yeah, and it's beautiful, folks.
01:12:47.920 --> 01:12:59.600
I mean I tweeted the other day that you know the AI hack is I now have like vibe I've gotten the AI to program me GitHub actions that like monitor when there's ever updates to WiWAM, J.
01:13:00.000 --> 01:13:08.800
And then whenever it notices an update, it automatically kicks up another GitHub action that goes and like pulls down the source, compiles it, gets the WASM executable.
01:13:08.960 --> 01:13:13.760
So now every once in a while I just get a pull request on this repo that says, hey, we got you the new version.
01:13:13.840 --> 01:13:14.960
I just click merge.
01:13:15.119 --> 01:13:15.680
It's beautiful.
01:13:15.840 --> 01:13:16.640
Everyone else was upset.
01:13:16.720 --> 01:13:19.520
They're like, oh, you've exposed yourself to supply J attacks.
01:13:19.680 --> 01:13:23.279
Listen, folks, if I get a supply chain attack, we're doing great.
01:13:23.439 --> 01:13:28.479
That means that people care enough about this website that they want to like, you know, uproot uh what I'm doing here.
01:13:28.560 --> 01:13:29.600
So we've got all the different languages.
01:13:29.920 --> 01:13:32.479
But you're only you're only try uh pulling from trusted people, right?
01:13:32.640 --> 01:13:32.880
Exactly.
01:13:33.279 --> 01:13:34.960
All the array programs you know personally.
01:13:35.600 --> 01:13:36.640
Corrupt one of the array lines.
01:13:37.039 --> 01:13:40.239
People are just so anti-AI that like they're like, oh, you know, that doesn't work.
01:13:40.319 --> 01:13:45.520
And it's like, I used to do this manually and it was it was so just like laborious, and now it's so pleasant.
01:13:45.680 --> 01:13:49.359
I just like I wake up in the morning, I'm so excited to go to my computer, I'm like, ooh.
01:13:49.680 --> 01:13:50.800
You heard that first, folks.
01:13:50.880 --> 01:13:59.359
Here, if you can put in a supply chain attack that puts some funny message on arraybox.com, Connor will give you a prize.
01:13:59.680 --> 01:14:00.880
Hey, I did that first.
01:14:01.119 --> 01:14:02.399
Madeline, uh yeah, that's true.
01:14:02.479 --> 01:14:07.359
That was before you were one of my went live and then was like, here, kinda trust AI too much.
01:14:07.600 --> 01:14:08.640
You know the sentence scene.
01:14:08.800 --> 01:14:09.840
I gave it to Madeline recently.
01:14:10.880 --> 01:14:14.399
Yeah, Madeline saying in the chat, you shouldn't trust me, and it's like, all right, well, that's my own fault.
01:14:14.479 --> 01:14:20.399
If you want to take down a RayBox with a uh you know, malicious release of Tiny Apple, it serves me right.
01:14:20.640 --> 01:14:31.359
But I was giving a uh uh talk recently at NDC Toronto just like a week and a half ago, and I used Tiny Apple uh for all of the code and like live coded the entire talk.
01:14:31.520 --> 01:14:35.119
And the reason that I used Tiny Apple is one, it has all the primitives.
01:14:35.199 --> 01:14:39.119
You know, when you look at the keyboard, it's just like holy smokes, we got everything, folks.
01:14:39.279 --> 01:14:40.800
Uh, and that's fantastic.
01:14:40.960 --> 01:14:51.680
In fact, I was thinking as soon as I was solving this in my head at the beginning, I was immediately mapping like, uh, what languages have primitives that would be a little bit nicer?
01:14:51.840 --> 01:14:56.720
And I thought, oh yeah, J has decrement and increment, which is plus one, minus one.
01:14:56.880 --> 01:15:03.199
That'd be nice, except for the fact that they're actually two characters in J, so it doesn't save you anything compared to like a minus one or a plus one.
01:15:03.359 --> 01:15:10.560
And then I forgot until I saw Madeline's solutions that, oh, that's right, uh uh Tiny Apple pretty much has everything.
01:15:10.720 --> 01:15:16.319
And so if you uh look at what the double dash except in a single Unicode primitive, this is decrement.
01:15:16.560 --> 01:15:20.239
Uh so you can I don't actually know if this saves, probably does save one character.
01:15:20.399 --> 01:15:26.079
Um but anyways, I uh I was mentioning that the reason I used Tiny Apple was one because it has all the primitives.
01:15:26.159 --> 01:15:31.680
Like I would have typically used BQN, but BQN didn't have the partition functions, partition and partition and close.
01:15:31.760 --> 01:15:32.640
And so I needed those.
01:15:32.720 --> 01:15:34.800
And then when you think, why wouldn't you use dialogue APL?
01:15:34.880 --> 01:15:36.159
Because dialogue APL has those.
01:15:36.239 --> 01:15:46.479
However, if we quickly copy this and we go to uh dialogue APL, if you try to uh output multiple things, so if I do like what do we just do?
01:15:46.640 --> 01:15:49.840
I guess we can just type a thing and then we do four, five, six.
01:15:50.000 --> 01:15:55.439
Because of the safety mechanisms that I put in place, you can well, is it because of this?
01:15:55.600 --> 01:16:02.800
Usually, actually, this says that I can't uh do this, or or maybe this isn't because of, but anyways, I'm using the Safe3 dialogue thing.
01:16:03.039 --> 01:16:11.119
And I don't know if that's what prohibits this, but multiple uh uh outputs don't work, whereas Tiny Apple, I have no problem.
01:16:11.359 --> 01:16:14.399
Uh I need I I just it just struck me now.
01:16:14.560 --> 01:16:33.920
I was uh I was at the BAA meeting, uh the Bridge APL Association at this bi-weekly meeting, and I was showing some old code that I converted from uh some APL 360 code, and I converted it to this MyServer thing that you can say interactive thing, and how I'd mangled the code so you can do things that sort of like session.
01:16:34.000 --> 01:16:45.520
And it just struck me now that maybe the safe code could do something like where it goes in and replaces all the quad get tokens, basically, uh dual tokens, with something that collects output.
01:16:45.680 --> 01:16:53.680
So it might not be able to show output in real time, but every when you run it, it will collect all the output and show you all the output you sped out on the way.
01:16:53.840 --> 01:16:54.720
I think I can do it.
01:16:54.960 --> 01:16:55.840
Yeah, potentially.
01:16:56.000 --> 01:17:00.960
Um anyway, so look forward to uh NDC Toronto uh it was called Algorithms and Combinators.
01:17:01.039 --> 01:17:14.720
It was a beautiful talk, folks, and I had a live coded, or well, not live coded, I had a vibe-coded live poll that was running like a reverse cloud fair tunnel on my laptop, and it had this beautiful pie chart animations of showing what languages people were using.
01:17:14.960 --> 01:17:16.399
Only possible thanks to AI.
01:17:16.479 --> 01:17:19.840
Um, but let's stop talking about AI and start talking about these solutions.
01:17:19.920 --> 01:17:20.880
So this was Madeline.
01:17:20.960 --> 01:17:26.079
So Madeline, creator, if you're not familiar, of the Tinel Tiny Apple language that we're looking at right now.
01:17:26.239 --> 01:17:29.600
So this is the uh index of solution, LOF or last index of.
01:17:29.840 --> 01:17:32.720
This is the key solution, and this is the original solution.
01:17:32.960 --> 01:17:35.520
So, I mean, we can look the through these primitives.
01:17:35.600 --> 01:17:45.119
So this is the group, which I believe uh initially comes from Cap and BQN, or maybe BQN had it first, and Cap added it later.
01:17:45.439 --> 01:17:50.800
And I don't fully actually so like this is so let's remark on the nice things first.
01:17:50.960 --> 01:17:58.000
So um uh Tiny Apple has the uh first, um, although it's called uh last.
01:17:58.239 --> 01:17:59.520
Uh and this is the first.
01:17:59.680 --> 01:18:01.520
So we've got first and last primitives.
01:18:01.680 --> 01:18:06.720
It's using the um cap syntax for forks in this case.
01:18:06.880 --> 01:18:12.399
Uh, and then we have the you know, max reduce, we have the decrement function, which is quite nice.
01:18:12.560 --> 01:18:14.880
What happened to my oh yeah, there we go, decrement.
01:18:15.359 --> 01:18:24.720
And uh this I was a bit confused of at first, but I'm pretty sure backward is just another way for the flip or swap.
01:18:25.039 --> 01:18:26.159
No, no, no, no, no.
01:18:26.239 --> 01:18:28.239
This is this is exactly what I was doing before.
01:18:28.399 --> 01:18:33.119
Look, this is the one that looks at the that's the the the classifier thing, right?
01:18:33.199 --> 01:18:35.199
We look for the first position in itself.
01:18:37.520 --> 01:18:43.359
So there's a backwards, it's basically a modifier, it's not a normal operator, it's special.
01:18:43.439 --> 01:18:50.159
I think it's use a lookup table and it modifies iota to behave from the back end, right?
01:18:50.319 --> 01:18:52.560
So so this is a variant, if you want.
01:18:53.039 --> 01:18:54.560
Really, it's just a spelling scheme.
01:18:55.039 --> 01:18:56.720
Iota of from the end.
01:18:57.119 --> 01:18:57.520
Yeah.
01:18:57.840 --> 01:19:07.439
So it's basically it's basically uh a primitive that could be spelled with multiple primitives as uh under reverse, correct?
01:19:07.680 --> 01:19:07.920
No.
01:19:08.079 --> 01:19:09.039
Uh no, exactly.
01:19:09.439 --> 01:19:14.079
Then I would have done that because you have to subtract from the it's it's position of the last, right?
01:19:14.399 --> 01:19:15.039
Oh, right, right.
01:19:15.520 --> 01:19:16.479
It's it's a different primitive.
01:19:16.560 --> 01:19:17.600
It's look for the last element.
01:19:17.680 --> 01:19:18.479
It's not the same thing as well.
01:19:19.680 --> 01:19:20.159
That's incorrect.
01:19:20.239 --> 01:19:20.479
Yeah, yeah.
01:19:20.560 --> 01:19:23.439
I should have the two words the tally minus earlier.
01:19:23.680 --> 01:19:23.920
Yeah.
01:19:24.079 --> 01:19:33.680
And uh Madeline in the chat is saying Elias, the creator of uh cap, uh, and uh they added them at the same time for the group primitive.
01:19:33.920 --> 01:19:35.199
Um so very beautiful.
01:19:35.279 --> 01:19:38.640
I mean, we've got the banana brackets in order to get the train syntax.
01:19:38.800 --> 01:19:58.720
And so this is the only thing that so I mean this is the group primitive from BQN, but it's uh equal group uh iota tally, which I don't I don't fully um and you can see that I had it here because except this was a mistake putting this because I wanted to I don't have uh actually I can just go up.
01:19:58.800 --> 01:19:59.920
Yeah, yeah, keep it this way.
01:20:00.000 --> 01:20:08.319
And you can see that I had it here because I was trying to just evaluate this, and if you get rid of can you do it with I don't think you can do it without that.
01:20:08.479 --> 01:20:10.640
Actually, no, wait, wait, wait, I'm doing this incorrectly.
01:20:10.800 --> 01:20:12.880
Uh I want to do shift enter.
01:20:13.039 --> 01:20:24.159
So this uh, which is just the equal group iota tally of the string, gives us the indices of the you know, a, b, and c oh.
01:20:24.560 --> 01:20:26.960
Is there some kind of thing going on?
01:20:27.039 --> 01:20:31.279
It's using the elements as the key into the group.
01:20:31.520 --> 01:20:32.399
Is it something like that?
01:20:32.640 --> 01:20:36.239
Well, so like it's grouping the indices, that's why it's doing the iota tally.
01:20:36.479 --> 01:20:38.159
So it's giving you need to get the indices first.
01:20:38.560 --> 01:20:40.319
This is just this is just a key, right?
01:20:40.399 --> 01:20:43.760
This is just yeah, but it's a key spelled of like five glyphs.
01:20:44.159 --> 01:20:46.720
Yeah, but the iota tally is the are the indices.
01:20:46.960 --> 01:20:48.079
Yes, iota tally exactly.
01:20:48.159 --> 01:20:56.079
That's what I'm saying to Connor, is the data you want to group is the indices, not the I think if you get rid of that, does it just group the characters?
01:20:56.560 --> 01:20:59.279
Uh or is there a write tech or something?
01:20:59.520 --> 01:21:00.079
Yeah.
01:21:00.319 --> 01:21:00.720
Yeah.
01:21:01.279 --> 01:21:06.479
So instead of grouping the characters, you want to group the indices at which they occur, which is the one.
01:21:06.640 --> 01:21:07.520
What is the equal do?
01:21:07.760 --> 01:21:13.199
I was gonna say I'm guessing that this has to be a binary operation that's passed to group.
01:21:13.359 --> 01:21:13.600
No.
01:21:14.239 --> 01:21:19.439
Well, they know because you've got the wrong domain there, you can't less than characters, but you might be on to something.
01:21:19.760 --> 01:21:21.039
Well, what is equal?
01:21:21.359 --> 01:21:22.399
Monetic equal.
01:21:24.960 --> 01:21:26.640
Madeline in the comments explain.
01:21:29.840 --> 01:21:30.640
Although, why is it blue?
01:21:31.119 --> 01:21:31.840
Oh, it's classifying.
01:21:31.920 --> 01:21:32.560
Oh, okay, okay, okay.
01:21:33.439 --> 01:21:34.079
It's classified.
01:21:34.239 --> 01:21:34.640
That's fine.
01:21:34.720 --> 01:21:36.159
So it's my docs have failed.
01:21:36.319 --> 01:21:37.760
My docs have failed.
01:21:38.000 --> 01:21:38.399
Yeah.
01:21:38.640 --> 01:21:43.039
No, because it's um Madeline forgot to cla document it.
01:21:43.119 --> 01:21:43.520
Uh-huh.
01:21:44.079 --> 01:21:50.079
Well, we can't blame Madeline yet because my guess is that it is documented and my scraping script missed it.
01:21:50.159 --> 01:21:55.039
Uh, I would I would trace try I trust the AI vibe coded uh doc scraper.
01:21:55.439 --> 01:21:59.279
Although never mind, it was it was Madeline's fault.
01:21:59.359 --> 01:22:01.920
She says, Oh, I did forget to document it.
01:22:02.720 --> 01:22:11.359
So this is if we go to uh BQN quickly um and we delete this, this is the and I can never remember how to spell this.
01:22:11.520 --> 01:22:12.800
I gotta is it this one?
01:22:12.960 --> 01:22:13.520
Is it this one?
01:22:13.840 --> 01:22:14.399
Is it this one?
01:22:14.640 --> 01:22:14.960
There we go.
01:22:15.279 --> 01:22:18.079
That one with is your cla is your group.
01:22:18.319 --> 01:22:19.039
No classify.
01:22:19.279 --> 01:22:19.600
There we go.
01:22:19.680 --> 01:22:22.960
So this is the idiom in this is classify, I think, right?
01:22:23.039 --> 01:22:26.560
So if we do F1 classify, and yeah, this is group.
01:22:26.880 --> 01:22:33.039
Uh so and this is an idiom that I um am very familiar with in BQN because it comes up a ton.
01:22:33.279 --> 01:22:38.399
So in uh Tiny Apple, it looks uh like it.
01:22:38.640 --> 01:22:48.079
I guess it would look like this in the case where you were grouping the own stuff, but in this case you actually want the fork where Iota tally is uh the right tyne.
01:22:48.239 --> 01:22:54.880
Um so yeah, this is a fork that is yeah, doing classify group on the indices.
01:22:55.119 --> 01:22:59.760
Which is, I mean, the uh we haven't said this for the audio listener, but this is definitely the most verbose solution.
01:22:59.920 --> 01:23:05.840
Then the key shaves off four characters or five, and the index of shaves off one more.
01:23:06.079 --> 01:23:18.159
Um although Madeline did mention that the index of for her uh Tiny Apple is actually much slower, but that's not because I don't think it couldn't be faster, it's just the implementation currently.
01:23:18.399 --> 01:23:39.199
Are there any other things worth remarking on in so I mean it's it's very love, this is why I love Tiny Apple though, because it's got you know the it's got the last, it's got the first, it's got all the primitives, and so whenever like it always makes me so sad when you go to BQN and you need you or you want like the decode and the encode, or you want the partition primitives.
01:23:39.439 --> 01:23:47.680
Um and uh for playing around, Tiny Apple it's always very nice because and that's the thing is I I wasn't even aware of this backward.
01:23:47.920 --> 01:23:53.199
Um but you can like maximally play around with the different algorithmic solutions for this.
01:23:53.520 --> 01:23:55.600
And uh I guess I should delete this at the point.
01:23:55.840 --> 01:24:00.079
And it makes me want to find the docs for backwards.
01:24:00.319 --> 01:24:00.800
There it is.
01:24:00.960 --> 01:24:03.680
So I mean I can't show other things that can do that.
01:24:03.840 --> 01:24:06.720
Oh, it doesn't say if I look at the full full docs.
01:24:07.359 --> 01:24:16.880
Backward doesn't tell you what things can go backwards, but the things that can go backwards oh also don't tell you because it was for because Madeline forgot to document it.
01:24:16.960 --> 01:24:17.920
Yeah, okay, fair enough.
01:24:18.159 --> 01:24:21.920
I just realized that I an optimization that I well, whatever.
01:24:22.000 --> 01:24:25.359
I weigh it's a nicer spelling of things, I think.
01:24:25.680 --> 01:24:30.800
And I guess this is the problem with not having a full panel, because there was a J solution at one point that didn't use key.
01:24:31.760 --> 01:24:32.640
I have a J solution.
01:24:33.199 --> 01:24:34.319
I have it to present.
01:24:34.479 --> 01:24:35.119
You want me to present?
01:24:35.359 --> 01:24:36.079
Yeah, yeah, yeah, sure.
01:24:36.880 --> 01:24:37.520
Steal it away from me.
01:24:38.640 --> 01:24:43.199
Um it irritates me because this YouTube recording, it's I'm staring up at my ceiling basically.
01:24:43.920 --> 01:24:47.039
So it's it's nicer if uh someone else's uh screen share.
01:24:49.439 --> 01:24:55.520
I'm not a J programmer, so I don't know what I'm doing here, but uh this seemed to work, and I just realized something.
01:24:55.840 --> 01:24:56.319
Oh, look at that.
01:24:56.479 --> 01:24:57.279
We're in Juno, folks.
01:24:57.359 --> 01:25:01.119
Look at that dovetailing from episode 124 with uh Juno.
01:25:01.840 --> 01:25:09.600
Uh so so this so this is the index of this is index of selfie, and this is index of last, which is a primitive in J selfie.
01:25:09.760 --> 01:25:10.800
So this is super easy.
01:25:10.960 --> 01:25:12.479
So subtract those from each other.
01:25:12.560 --> 01:25:15.760
Maybe I should tokenize this for you because I can I can't read J like this.
01:25:15.920 --> 01:25:16.159
Sorry.
01:25:16.399 --> 01:25:19.359
I mean it has different colors and it's all nice here, but uh seriously I can't.
01:25:19.840 --> 01:25:29.199
Uh okay, so index of last selfie, uh minus index of first selfie, maximum nothing over here.
01:25:29.279 --> 01:25:32.399
This is the cap uh thing, and then subtract one.
01:25:32.479 --> 01:25:33.680
So this is this is a solution.
01:25:33.840 --> 01:25:37.520
And I just realized together, you can put the slash next to the max.
01:25:38.079 --> 01:25:38.479
What?
01:25:38.720 --> 01:25:39.119
Right?
01:25:39.279 --> 01:25:39.840
Is that right?
01:25:40.000 --> 01:25:40.399
Right.
01:25:40.640 --> 01:25:42.960
Uh is yeah, that's one thing.
01:25:43.199 --> 01:25:45.439
Yeah, I mean if you want, but this is the thing.
01:25:47.039 --> 01:25:47.359
Yeah.
01:25:49.680 --> 01:25:53.439
I just realized a couple of things, a couple of things that are nice here.
01:25:53.600 --> 01:26:01.760
One is I believe, and we can apply this to the APL, we can go back and do the APL afterwards, is we can break out the selfie over here, I believe.
01:26:02.079 --> 01:26:03.119
Uh like that.
01:26:03.359 --> 01:26:09.119
That still works because it's just a now it's just indexed off the left argument, which is so it's not as so that's nice.
01:26:09.359 --> 01:26:12.479
And this, I believe we can make this an inner product.
01:26:12.800 --> 01:26:19.600
But the inner product is not spelled any better in J, really, because you have to do like this, I think, to do inner product, but it gets rid of the can.
01:26:21.439 --> 01:26:24.479
Yeah, in J you do, but not in the okay, fair enough.
01:26:24.800 --> 01:26:26.960
Um and then so this is this is the whole solution.
01:26:27.039 --> 01:26:28.159
We can get rid of the spaces now.
01:26:28.239 --> 01:26:29.039
We can almost read it.
01:26:29.439 --> 01:26:35.600
Max dot minus can't remove this space, I believe, because then it's dot slash, which means something completely different.
01:26:35.840 --> 01:26:38.319
Uh but this is pretty nice, isn't it?
01:26:38.640 --> 01:26:44.479
Minus one plus the slightly shorter max dot minus index of the first.
01:26:44.800 --> 01:26:45.840
Can't you do a decrement?
01:26:46.000 --> 01:26:47.199
Or is that gonna be longer?
01:26:47.760 --> 01:26:52.159
Oh yeah, we can do a decrement, but it doesn't help because that would need a cap.
01:26:52.640 --> 01:26:53.039
Right.
01:26:53.199 --> 01:26:55.359
Because because you can't do a tops like this.
01:26:55.439 --> 01:26:57.680
So it doesn't really that's the worst part of J, folks.
01:26:58.159 --> 01:27:05.119
I say it because Henry's not here, but uh the the two train being the S combinator, frankly, big mistake.
01:27:07.920 --> 01:27:09.039
is key in J.
01:27:09.359 --> 01:27:10.479
Yeah, so we can use key.
01:27:10.560 --> 01:27:12.079
Yeah, but it's not not just slash dot.
01:27:12.239 --> 01:27:16.399
I think there's two keys because they realized that the dialogue key was so nice that they wanted that too.
01:27:16.560 --> 01:27:20.479
So there's so this is the key, and then there's like well that was Roger's fault, was it?
01:27:20.960 --> 01:27:25.680
Uh he brought uh J stuff into the key diet, yeah.
01:27:25.760 --> 01:27:26.319
This one.
01:27:26.560 --> 01:27:29.279
But anyway, so yeah, you can use it with the key.
01:27:29.359 --> 01:27:31.119
I'm not really sure how that works.
01:27:31.279 --> 01:27:35.520
We can try it if you want, but I'm not I mean scary stuff.
01:27:36.319 --> 01:27:38.159
Unknown territory here for AP.
01:27:39.039 --> 01:27:40.000
AKLE killers.
01:27:40.399 --> 01:27:43.840
I think we like like enclosed uh that did not work.
01:27:44.079 --> 01:27:47.039
Oh right, because we want I'm not doing I don't even know.
01:27:48.640 --> 01:27:49.039
That's right.
01:27:49.119 --> 01:27:49.279
Yeah.
01:27:49.760 --> 01:27:52.479
No, no, it's not because this doesn't give us the the indices.
01:27:52.800 --> 01:27:54.800
No, no, you have to provide the indices.
01:27:58.000 --> 01:27:59.279
So it's in an I dot.
01:28:00.399 --> 01:28:01.680
Like a hook or something.
01:28:02.000 --> 01:28:08.159
Uh we have to do like or uh compose i dot compose with the tally.
01:28:08.560 --> 01:28:08.800
Yeah.
01:28:09.119 --> 01:28:11.039
Just like this or something like that, right?
01:28:11.359 --> 01:28:12.800
Yeah, so these are the indices.
01:28:13.199 --> 01:28:15.760
And then we want to group by indices.
01:28:15.840 --> 01:28:20.479
So we want to group like oh, I think now we can use the copy thing.
01:28:20.640 --> 01:28:24.079
Uh oh, it's probably it's probably the wrong argument order.
01:28:24.479 --> 01:28:27.600
Imagine is does J have a regex engine inbuilt?
01:28:28.640 --> 01:28:30.159
It looks it looks the same.
01:28:30.319 --> 01:28:34.239
I don't know how to use the key here correctly on the indices.
01:28:34.319 --> 01:28:38.960
We want to we want to group the indices, but how do we supply what the keys are?
01:28:39.279 --> 01:28:42.479
If there's a J uh programmer uh in the chat.
01:28:42.800 --> 01:28:53.439
I mean there was one earlier, but um Have they explored the approach to only use the index of first and index of the element in the vector.
01:28:55.039 --> 01:28:58.560
I'd fill up the dot after slash uh for key.
01:29:01.520 --> 01:29:04.000
Okay, yeah, so these are all the indices, right?
01:29:04.159 --> 01:29:06.960
And so instead of the this is the enclose.
01:29:07.199 --> 01:29:10.079
So I think marble we'll come back to what marble command is.
01:29:10.319 --> 01:29:12.720
Okay so here inside here we want well, okay.
01:29:12.800 --> 01:29:14.479
It does the parenthesis thing for me.
01:29:14.640 --> 01:29:16.239
We want to do the first and the last.
01:29:16.319 --> 01:29:18.079
Is there there's a head and tail?
01:29:18.399 --> 01:29:21.199
Yeah, it's uh brace colon and brace dot.
01:29:21.760 --> 01:29:25.520
Open brace and yeah, open brace dot.
01:29:26.000 --> 01:29:27.039
Uh this.
01:29:27.359 --> 01:29:29.359
Uh it's actually the last one we want, right?
01:29:29.600 --> 01:29:31.039
Last minus first.
01:29:31.279 --> 01:29:34.159
Yeah, I can never remember which is which, but you know, you just you just switched.
01:29:34.239 --> 01:29:34.560
There we go.
01:29:34.720 --> 01:29:36.399
You try both and one of them will work.
01:29:36.880 --> 01:29:37.600
Exactly.
01:29:37.760 --> 01:29:38.239
There you go.
01:29:38.399 --> 01:29:42.399
So now we we now we got this far, and now we just want to do the minimum on this.
01:29:42.720 --> 01:29:43.279
Right.
01:29:43.600 --> 01:29:49.600
So the minimum is X less than dot, but we can't we have to cap it.
01:29:49.920 --> 01:29:50.720
No, that's not right.
01:29:50.800 --> 01:29:52.800
We don't want to do the minimum, we want to do the maximum minimum.
01:29:54.640 --> 01:30:00.399
And then we want to do we want to um subtract one from this.
01:30:00.560 --> 01:30:04.560
So negative one plus, or we can decrement, which doesn't help anything.
01:30:04.960 --> 01:30:06.079
Just more caps.
01:30:06.399 --> 01:30:12.079
We could technically speaking glue it together with decrement over here, with decrement minus dot or something.
01:30:12.399 --> 01:30:13.279
I don't know.
01:30:13.600 --> 01:30:17.359
Uh decrement is wait, hold on.
01:30:17.600 --> 01:30:19.119
Uh less of that.
01:30:19.680 --> 01:30:20.319
Decrement.
01:30:20.560 --> 01:30:21.920
Less than colon.
01:30:22.079 --> 01:30:23.119
Of course it is.
01:30:26.880 --> 01:30:27.680
Of course it is.
01:30:27.920 --> 01:30:29.840
Uh and that was not right anymore.
01:30:29.920 --> 01:30:30.399
I don't know.
01:30:30.560 --> 01:30:32.239
I can't read this stuff.
01:30:32.640 --> 01:30:34.640
I mean we got the we get the impression.
01:30:34.800 --> 01:30:40.079
Oh, we got the the bulk of the colons because they got like the combinator.
01:30:41.760 --> 01:30:44.399
Yeah, it's got extra colons for good order.
01:30:45.199 --> 01:30:49.199
See if you're on a ray box, you could have just gone control space and typed in decrement.
01:30:49.359 --> 01:30:50.960
You never need to memorize anything anymore.
01:30:51.279 --> 01:30:52.159
Okay, thank you.
01:30:52.479 --> 01:30:54.239
That's uh is that true?
01:30:54.399 --> 01:30:55.760
I'm going on a ray box now.
01:30:55.840 --> 01:30:57.119
Yeah, well, I'll steal it back to the box.
01:30:57.840 --> 01:30:59.359
This was interesting, right?
01:30:59.520 --> 01:31:06.880
Because this means that in J, this solution was so much better, the one like so much nicer as well.
01:31:07.359 --> 01:31:08.079
Actually read that.
01:31:08.239 --> 01:31:23.439
Now I'm gonna I want to go back to APL for a moment because if you look at um this in G, we could actually well it doesn't actually matter because this is the this is the last index.
01:31:23.600 --> 01:31:34.399
Sorry, and I'm gonna by the way, I'm working on a new keyboard solution for dialog APL, and I'm gonna steal APL space as a default shortcut for a keyword search.
01:31:36.640 --> 01:31:37.520
It's control space.
01:31:37.840 --> 01:31:39.520
Well, it's depends what you want.
01:31:39.680 --> 01:31:42.880
Uh your maybe it will just be settable to whatever you want.
01:31:43.119 --> 01:31:43.359
Yeah, yeah.
01:31:43.520 --> 01:31:45.760
And I I wasn't the one that came up with it.
01:31:45.840 --> 01:31:48.239
It's it's on, I think CAP has a version of it.
01:31:48.319 --> 01:31:55.439
There, you know, I everything on Array Box is just an amalgamation of all the best things across every single REPL in all the different array languages.
01:31:55.840 --> 01:31:56.239
For sure.
01:31:56.560 --> 01:32:01.199
So so just what I what I thought of here is an APL is sort of nice to do an inner product here.
01:32:01.279 --> 01:32:02.319
I don't know if you like that.
01:32:02.399 --> 01:32:03.760
It's just it's not shorter.
01:32:03.920 --> 01:32:09.199
It's just because it's a reduction over mixed effective, like you could do it.
01:32:09.359 --> 01:32:15.359
It would be nice if if we had like a yOTA dot whatever, like an index of last.
01:32:16.159 --> 01:32:19.439
Um all right, can I steal it back to show marble comas?
01:32:19.600 --> 01:32:20.960
Yeah, good technically credits.
01:32:21.279 --> 01:32:23.600
Uh I'm gonna pronounce this wrong, but I'll do my best.
01:32:23.760 --> 01:32:27.359
Adrax uh has a optimal Wiwa solution.
01:32:27.439 --> 01:32:36.239
And seeing as we we don't have the J representative, we don't have the Wi WA representative, we're just doing our best to showcase all the different uh array languages.
01:32:36.479 --> 01:32:48.960
So if we come here and um so yeah, this just to you know highlight on screen what I was mentioning, if you're in J or whatever you wiwa and you don't know how to type it, I mean in wiwa, you can just you know type the name of it.
01:32:49.039 --> 01:33:01.199
So you don't really need this, but uh you you know you can do stuff and and find it, which a lot of the times there's a subset in J and in BQN and definitely in Tiny Apple that I do not know how to type.
01:33:01.359 --> 01:33:10.159
Um anyway, so this is the optimal from by way of marble coma or or by from Adorax by way of marble coma in the YouTube chat.
01:33:10.239 --> 01:33:18.960
So this is the benefit of doing this on YouTube is uh we can fill in our lack of expertise in the array languages that we're not good at and uh borrow them from them.
01:33:19.039 --> 01:33:31.359
So I believe this is classify in um WeWah, and then this is unselect, which actually I don't I don't have the log is classify, bro.
01:33:31.920 --> 01:33:33.279
So do they have it?
01:33:33.600 --> 01:33:37.920
So I don't have the name of this, but there's a bunch of idioms that I scraped from the Wiwa docs.
01:33:38.399 --> 01:33:41.359
Uh and they have names, I think, half the time.
01:33:41.520 --> 01:33:45.840
So unselected, or like I don't know what it corresponds to, but this is an idiom.
01:33:46.000 --> 01:33:48.479
Um what I can I not get rid of this.
01:33:48.720 --> 01:33:52.239
And then we have, I believe this is complement or not, as they call it.
01:33:52.479 --> 01:33:58.079
Plus, uh this is minimum, and then unselect this enumerate an array, right?
01:33:58.239 --> 01:33:59.600
Oh, yeah, totally.
01:33:59.920 --> 01:34:00.239
What am I doing?
01:34:00.479 --> 01:34:02.399
Yeah, let's just let's just get rid of this.
01:34:02.640 --> 01:34:03.119
Get rid of this.
01:34:03.840 --> 01:34:04.399
Unselect.
01:34:04.800 --> 01:34:09.359
I can just uh yeah, we would have been able to see this if I just evaluated this like this.
01:34:09.439 --> 01:34:11.920
So yeah, it's enumerate zip with index basically.
01:34:15.279 --> 01:34:16.960
In front because it's stack based, right?
01:34:17.199 --> 01:34:18.079
It's stack based.
01:34:18.239 --> 01:34:20.159
Oh a lot of things are backwards, right?
01:34:20.239 --> 01:34:30.640
Like every every function including uh binary operations are are prefix and uh so something's no diode, it's stack based, right, right, right.
01:34:30.880 --> 01:34:34.159
And then if you do not, ooh, actually, that's interesting.
01:34:34.640 --> 01:34:40.640
The not of your indices is actually one minus.
01:34:40.960 --> 01:34:41.680
Is that right?
01:34:41.920 --> 01:34:43.039
Did I just do that correctly?
01:34:43.439 --> 01:34:44.239
One minus, yeah.
01:34:44.399 --> 01:34:49.840
And so because you have zero index, it's one zero, negative one, negative two, negative three, negative four.
01:34:50.479 --> 01:35:06.479
And if we Oh, and then you add those together then that is like subtracting the indices from the last from the indices from the first from the beginning, indices of the last from indices of the first.
01:35:07.279 --> 01:35:08.079
Breaking my brain.
01:35:08.399 --> 01:35:10.239
No, no, I yeah, it's there.
01:35:10.880 --> 01:35:13.039
So classify totally makes sense.
01:35:13.199 --> 01:35:17.760
If you have the string ABC C V A, you get 012210, that's fine.
01:35:18.239 --> 01:35:31.119
Unselect zips with the indices, then you take the complement or not of the indices, and that's effectively programmed as one minus, which uh Yeah, that's that comes from BQN.
01:35:31.199 --> 01:35:37.840
It was because of fuzzy logic, that the the pro the probability of something not happening is one minus the probability of something happening.
01:35:38.079 --> 01:35:39.600
So that's why not is one minus.
01:35:40.000 --> 01:35:50.800
But in this case, it you ri you end up your indices are transposed to or not transposed, transformed to one zero, negative one, negative two, negative three, negative four.
01:35:50.880 --> 01:36:01.680
And then when you add that transformed index sequence with your classify sequence, you end up for the case of ABC C B A 11102 negative four.
01:36:02.000 --> 01:36:03.520
No, you're right, I'm lost again.
01:36:03.760 --> 01:36:05.760
Yeah, and then whether that makes sense.
01:36:06.000 --> 01:36:07.600
Uh or what it's for.
01:36:08.159 --> 01:36:13.840
So it's and then and then so there is an absolute value at the end, which might make more sense if we do that.
01:36:14.239 --> 01:36:15.279
No, it's the distance.
01:36:15.359 --> 01:36:21.359
It's the distance to the uh actually wait, but you need it to be in front because they're doing a minimum here.
01:36:23.920 --> 01:36:26.239
This is if we go back to the plus, go back to the plus.
01:36:26.319 --> 01:36:29.359
I'm pretty sure that's the distance from this element.
01:36:29.520 --> 01:36:31.199
Can you stick another C on the end?
01:36:32.560 --> 01:36:33.439
Is that the distance?
01:36:33.520 --> 01:36:37.840
So that C is three characters away from the first C.
01:36:38.159 --> 01:36:41.119
And the A is four characters uh one, two, three, four.
01:36:41.199 --> 01:36:43.039
Yeah, four characters from the first A.
01:36:43.359 --> 01:36:45.760
And the B is two characters from the first B.
01:36:45.840 --> 01:36:51.359
But the first C is uh does that make sense?
01:36:51.520 --> 01:36:52.640
One, one, one, zero.
01:36:53.039 --> 01:36:56.319
I think C is zero characters from the previous C.
01:36:56.800 --> 01:36:59.520
Well, there are zero characters in between that and the previous C.
01:36:59.600 --> 01:37:04.399
And the second one, there are three characters between that C and the very first C.
01:37:04.800 --> 01:37:16.000
Yeah, yeah, because the property of the classify, similar to what Adam was talking about earlier when we were doing the uh Dyadic Iota selfie, is that it's the first index.
01:37:16.159 --> 01:37:19.760
It's not just like the category, it's not just the label, it's the first index of it.
01:37:19.920 --> 01:37:27.279
And so if you do this, I mean it's still a little bit mind-bending that No, but that's it, right?
01:37:27.359 --> 01:37:29.680
That's giving you the Yeah.
01:37:29.920 --> 01:37:38.239
It's it's just a little bit mind-bending because the transform index sequence, it's not zero to negative six, it's one zero and then negative one to negative five.
01:37:38.399 --> 01:37:51.840
But when you add that to the classify, you get back basically a maybe off by one distance from the character to the first instance of that character.
01:37:52.000 --> 01:37:52.239
Yeah.
01:37:52.479 --> 01:37:54.720
Which happens to be exactly what we want.
01:37:54.960 --> 01:38:00.800
And then the the confusing part is that you have to go minimum and then absolute value.
01:38:00.960 --> 01:38:05.039
I mean minimum absolute value is just is it is it though?
01:38:05.199 --> 01:38:10.000
Because uh just negate uh Madeline says you need to negate.
01:38:10.319 --> 01:38:14.319
Otherwise, in that when they're all different, it's probably negate.
01:38:14.479 --> 01:38:16.239
Otherwise, when they're all different, you get it wrong.
01:38:16.319 --> 01:38:18.399
If you do absolute, then negative one becomes one.
01:38:18.560 --> 01:38:19.279
You don't want that to one.
01:38:19.439 --> 01:38:19.840
Yeah, yeah, yeah.
01:38:21.119 --> 01:38:21.520
Alright.
01:38:22.479 --> 01:38:23.039
Wild.
01:38:23.520 --> 01:38:25.520
J with ligatures sounds amazing.
01:38:25.840 --> 01:38:33.680
J with ligatures sounds like actually why did this one oh yeah, because I I put in stacks instead of min.
01:38:34.720 --> 01:38:43.439
So technically, I guess, yeah, I guess this would be a lot longer in because there's no zip width index.
01:38:43.680 --> 01:38:50.479
I mean you could spell it with range pair, but you're gonna need at least uh a before or a fork.
01:38:50.880 --> 01:38:52.159
It has classify.
01:38:52.640 --> 01:38:56.159
So I mean actually, let's see, let's see how if I go to BQM, which I believe is right above.
01:38:57.279 --> 01:38:57.760
Translate.
01:38:58.159 --> 01:39:05.600
So this is you know, classif classify, and then this is what uh let's just comment this out for the moment.
01:39:05.680 --> 01:39:06.479
Is that gonna work?
01:39:07.039 --> 01:39:09.600
Um, I didn't mean to get rid of everything.
01:39:09.760 --> 01:39:14.720
So we have classify, and why I guess this needs to be in a fork.
01:39:20.319 --> 01:39:20.800
Oh right.
01:39:20.960 --> 01:39:22.880
There needs to be a there needs to be a length in here.
01:39:23.680 --> 01:39:24.960
Alright, so this looks right.
01:39:25.119 --> 01:39:28.319
So here's our classify sequences on the right down here.
01:39:28.560 --> 01:39:34.960
And then now we have our uh enumerate, except we don't actually want to enumerate, so we just want this actually.
01:39:35.199 --> 01:39:40.560
Um now we want to do our complement, if I can type that correctly.
01:39:40.720 --> 01:39:43.279
And now we want to do was it plus?
01:39:43.439 --> 01:39:45.439
Oops, I got rid of something I should have gotten rid of.
01:39:47.520 --> 01:39:54.159
Then the pattern was we want a min reduce and an absolute value, which is absolutely negate, not absolute.
01:39:54.720 --> 01:39:55.840
Negate, not absolute?
01:39:56.159 --> 01:40:03.680
Yeah, because if they're all different, negative one becomes I can't remember the explanation, but it's it should be minus.
01:40:03.840 --> 01:40:07.439
Oh right, but then uh I'm so close.
01:40:07.680 --> 01:40:11.039
This is right, I need uh nothing before this.
01:40:11.199 --> 01:40:11.760
There we go.
01:40:11.840 --> 01:40:13.520
And so can this be golfed?
01:40:13.680 --> 01:40:17.039
Um looks pretty tight to me, I don't know.
01:40:17.199 --> 01:40:22.319
Uh yeah, you can a little bit because you can flip you have a fork on the right, right?
01:40:22.399 --> 01:40:24.159
But it's parenthesized left side.
01:40:24.560 --> 01:40:28.800
Don't we still need to use something we'd need to or I guess maybe just glue them?
01:40:29.520 --> 01:40:30.319
Oh, just glue them.
01:40:31.600 --> 01:40:33.039
Another term, another turn.
01:40:33.439 --> 01:40:33.840
Oh yeah.
01:40:33.920 --> 01:40:37.359
I I I I fail to so fork brained.
01:40:37.520 --> 01:40:47.520
Um I mean to be fair, like passing wise, I like I personally like grouping, you know, bits and parentheses, even when I write frames and stuff.
01:40:48.000 --> 01:40:48.880
He wanted it to go off.
01:40:50.640 --> 01:40:57.840
I mean, I I I agree that like you know, if I'm writing it in code, I probably would have I probably would have left it like that because this is much more I agree with Rich.
01:40:58.000 --> 01:40:59.359
It's much more impenetrable.
01:40:59.600 --> 01:41:04.319
Well you gotta figure out like uh the there's two jots there, and one of them's doing one thing and the other one's doing well.
01:41:04.479 --> 01:41:06.000
I guess it's not, but it is.
01:41:06.239 --> 01:41:06.880
I don't know.
01:41:07.119 --> 01:41:14.880
I wonder if someone like Marshall, like if he instantly sees this and then knows like that's a unary function and that's a fork, or I don't know.
01:41:15.279 --> 01:41:16.560
What what are you guys are the pros?
01:41:16.800 --> 01:41:19.039
Like, uh I guess Rich, you said yet it's still hard to parse.
01:41:19.119 --> 01:41:19.760
What about you, Adam?
01:41:19.840 --> 01:41:20.640
Like, do you instantly see these?
01:41:20.960 --> 01:41:36.079
Yeah, yeah, I've gone over the other side of tacit and uh less of a I see I sort of see those screws together, but it bothers me that things that are adjacent with no combinator between them are more distant from each other than things that are uh that are bound together.
01:41:36.399 --> 01:41:43.680
So people are saying in the chat that you know that uh J with ligatures might be interesting.
01:41:44.159 --> 01:41:50.640
Uh I'm thinking valuable concepts uh it still spans the width of two characters though.
01:41:50.720 --> 01:41:52.079
So I don't know what we're talking about here.
01:41:52.159 --> 01:41:56.239
Like it didn't have to, it could be it could be variable width, right?
01:41:56.399 --> 01:42:01.359
Is it so no but I'm thinking about that the ligature changes two characters into a single character?
01:42:01.520 --> 01:42:02.239
Is that possible?
01:42:02.720 --> 01:42:07.119
Yes, yeah, yes, you have, but you never notice because those are not coding fonts, right?
01:42:07.279 --> 01:42:09.119
Yeah, because any normal fonts are enough.
01:42:09.199 --> 01:42:12.319
I'm talking about Jeffrank mono and and sibling fonts that have ligatures.
01:42:12.640 --> 01:42:18.319
If you write F lowercase F, lowercase j in the normal font, it puts the F and the J together.
01:42:18.399 --> 01:42:19.760
That's where ligature comes from.
01:42:19.920 --> 01:42:21.600
Using it for programming is a heck.
01:42:22.319 --> 01:42:25.199
Um so or FI, right?
01:42:25.279 --> 01:42:26.239
It's a classic one.
01:42:26.479 --> 01:42:32.960
Anyway, so maybe like for code for API code, I don't mind so much it being variable width.
01:42:33.279 --> 01:42:35.600
For arrays, they need to be monospace.
01:42:35.760 --> 01:42:38.239
But let's just say there was a way to make that all work out.
01:42:38.479 --> 01:42:50.800
Imagine if the spacing between the glyphs was larger when there was no combinator between them, but then the combinator was like narrow and like pulled them together so they would sort of look nicer, sort of healing.
01:42:51.039 --> 01:42:51.439
Yeah.
01:42:51.680 --> 01:42:54.560
I guess yeah, I'm kind of I'm kind of code golf brain.
01:42:54.720 --> 01:43:06.000
So my my desire is that like when you have if you if you're trying to replace one plus or uh you know some equivalent with increment, it's like well what did I what did I actually do there?
01:43:06.079 --> 01:43:14.399
It's only useful if you need some tacit thing and it saves you like you know a cap or whatever because you can keep things in some you know fork mode or whatever.
01:43:14.640 --> 01:43:21.039
Um but like yeah, tiny apple is much, much better in my opinion, because it's a single Unicode symbol.
01:43:21.279 --> 01:43:33.039
Anyways, have we have we missed there's been a bunch of um comments in the YouTube chat as we wind things down, seeing as we're a full half hour past the 90 minute mark.
01:43:33.199 --> 01:43:36.479
I like how Rich was we gotta share the tiny apple.
01:43:36.560 --> 01:43:38.880
We were it's at 83 minute mark, and then boom.
01:43:39.119 --> 01:43:41.920
Oh, I didn't realize there was a desire to keep it at 90.
01:43:42.239 --> 01:43:46.479
Oh, I think I have a uh was that established at the in the first five minutes when I wasn't here.
01:43:46.880 --> 01:43:49.760
Ever since ever since the beginning of a rake catch, there's supposed to be 90 minutes.
01:43:50.000 --> 01:43:53.680
I can kind of yeah, I well yeah, but I did kind of look at the also the links.
01:43:54.000 --> 01:44:01.840
No, I didn't have a a final uh entry here, which is writing Perl in APL, basically.
01:44:02.079 --> 01:44:04.880
Solving this using regx in dialogue APL.
01:44:04.960 --> 01:44:06.479
No, the wrong tool for the job.
01:44:06.560 --> 01:44:07.359
Let's do it.
01:44:07.920 --> 01:44:08.319
Yeah, yeah.
01:44:08.640 --> 01:44:09.119
All right.
01:44:09.279 --> 01:44:09.600
Okay.
01:44:10.239 --> 01:44:14.239
Although my wife said uh I've got two minutes, so hopefully you can do this in two minutes.
01:44:14.640 --> 01:44:16.159
I can I think so.
01:44:16.399 --> 01:44:17.840
So so I think this works.
01:44:18.000 --> 01:44:20.960
I haven't made it into a single function, although that shouldn't be hard.
01:44:21.039 --> 01:44:23.439
It I think it just it just comes out to a train.
01:44:23.680 --> 01:44:24.720
So we can do that.
01:44:24.960 --> 01:44:26.399
But it looks completely insane.
01:44:26.720 --> 01:44:27.520
Yeah, that okay.
01:44:27.600 --> 01:44:42.079
So so what's happening here is essentially this is the search function, and it's looking for any one character followed by any number of characters, and then a back reference to the first same character again, which is what we're looking for, right?
01:44:42.319 --> 01:44:52.880
So any sequence that begins and ends with the same character, and we don't care whatever is in the middle, and it's greedy, so it wants to make them as long as possible, but we want to catch overlapping matches.
01:44:52.960 --> 01:44:57.039
So this is the variant that says open overlapping matches is set to one.
01:44:57.359 --> 01:45:09.359
And we don't actually want the result of the search, we just want to know the length of the result, which is the code one for the result instead of returning a text, we return that over there.
01:45:09.439 --> 01:45:15.039
So I'll I'll shorten this for a moment just over here and and use the uh and symbol.
01:45:15.279 --> 01:45:17.760
This gives us all the matches that it could find.
01:45:17.920 --> 01:45:25.039
If we add some more like some B's in here, so we can see that we find the maximum A up here to B, right?
01:45:25.279 --> 01:45:28.000
So these are all the possibilities, all the candidates.
01:45:28.239 --> 01:45:31.199
But we don't want the that, we just want the length of each one.
01:45:31.359 --> 01:45:32.720
So we replace this with a one.
01:45:32.960 --> 01:45:34.319
So this is length eight.
01:45:34.560 --> 01:45:40.960
And then we want to subtract, but remember this counts the length of the first and the last character included.
01:45:41.039 --> 01:45:43.600
We only want actually the length of of the middle one.
01:45:43.760 --> 01:45:50.880
So we could extract the middle one, but it's easier to just uh to just subtract one from it here.
01:45:51.359 --> 01:45:53.119
Um is that actually true?
01:45:53.199 --> 01:45:55.039
Is that the shouldn't we subtract two?
01:45:56.159 --> 01:45:58.319
Let's make a shorter example just to see here.
01:45:58.640 --> 01:46:02.159
So this should give us yes, oh, it gives length two.
01:46:02.319 --> 01:46:10.000
So we need to subtract two over here, and then there's one problem that is if there aren't any uh matches, we need to get negative one.
01:46:10.239 --> 01:46:15.680
So if I if there aren't any matches, it gives us an empty list, and then we try to do the maximum empty list, that's no good.
01:46:16.000 --> 01:46:20.159
Uh because that gives us the identity element, which is negative infinity, so we don't want that.
01:46:20.560 --> 01:46:24.560
Um actually, and we could be trickery with this, but whatever.
01:46:24.720 --> 01:46:27.920
So this is the uh this gives us three, one, two, three.
01:46:28.000 --> 01:46:29.119
That's this one over here.
01:46:29.279 --> 01:46:33.920
And if there aren't any matches, we get negative one because I just stuck that in there.
01:46:34.239 --> 01:46:37.119
The problem is we get inf negative infinity.
01:46:37.520 --> 01:46:38.960
So there is something we could do here.
01:46:39.039 --> 01:46:45.199
We could be a little bit tricky and just say like negative one with maxed with that, but that's just that's just silly.
01:46:45.359 --> 01:46:47.359
Uh it doesn't save save us anything.
01:46:47.520 --> 01:46:54.079
Anyway, so this is a uh this is a solution uh using ragex in dial like APL.
01:46:54.159 --> 01:46:55.279
Forget you ever saw this.
01:46:55.359 --> 01:46:56.079
Don't do this.
01:46:56.239 --> 01:47:00.319
This is for sure going to be the slowest solution of them all, and it only works on characters.
01:47:00.560 --> 01:47:02.479
So uh yeah, never mind.
01:47:02.640 --> 01:47:04.800
You will also fail and all kinds of other things.
01:47:04.960 --> 01:47:06.239
Well, now you've seen that.
01:47:06.560 --> 01:47:07.279
There we go, folks.
01:47:08.640 --> 01:47:09.520
We should call it a day.
01:47:09.600 --> 01:47:12.000
He didn't do it in two minutes, but three and a half is pretty good.
01:47:12.079 --> 01:47:15.600
And uh doing Pearl better than Pearl uh you know does it.
01:47:15.680 --> 01:47:24.399
Technically, you know, this problem came from Pearl Weekly Challenge, but every once in a while I look at the Pearl solutions and they they try and make it look like Python and like very variables all over the place.
01:47:24.479 --> 01:47:30.560
And uh I tried to find the solution, they don't have it, but I the solution for the first one is like hardly using regex at all.
01:47:30.720 --> 01:47:34.720
So APL, doing Pearl better than Pearl, and I guess that's where we'll leave it.
01:47:34.800 --> 01:47:36.000
So we saw what did we see?
01:47:36.079 --> 01:47:39.760
We saw uh we saw some J, we saw some APL, we saw some Tiny Apple, we saw some Wiwa.
01:47:40.000 --> 01:47:44.159
We did see a little bit of BQN at the end too, and uh the only thing we didn't see is Cap.
01:47:44.399 --> 01:47:48.079
So I guess we gotta bring Ellias on or something to make up for that at some point.
01:47:48.319 --> 01:47:53.119
Uh thanks to Adam and Rich for um hopping on and and chatting about this.
01:47:53.199 --> 01:48:02.560
I think this honestly turned out so much better than not that I thought it was gonna be bad, but I didn't think it was gonna be one of our like, you know, better episodes of covering a bunch of different primitives and solutions.
01:48:02.800 --> 01:48:07.920
If folks have their solutions, uh post the live recording of this.
01:48:08.079 --> 01:48:10.560
Feel free to share them in the the YouTube comments.
01:48:10.720 --> 01:48:14.800
You can also reach us at arraycast contact at arraycast.com.
01:48:14.960 --> 01:48:18.319
If we have access to the email, we I think we kind of quasi got blocked out.
01:48:18.479 --> 01:48:20.000
Adam I need to figure that out.
01:48:20.079 --> 01:48:21.359
Uh we should have continued.
01:48:22.239 --> 01:48:28.560
Luckily, uh you can log into the YouTube account uh without having to log into the Gmail first.
01:48:28.640 --> 01:48:32.880
So I was worried we lost access to the YouTube account, but we still have access to that.
01:48:33.039 --> 01:48:34.479
Uh once again, thanks.
01:48:34.640 --> 01:48:39.039
And I guess with that, we will say happy array programming programming.
01:48:39.439 --> 01:48:42.399
Uh it's been a while.
01:48:42.960 --> 01:48:44.159
Happy array programming.
01:48:44.239 --> 01:48:45.680
I didn't know you can do it at the same time.
01:48:45.760 --> 01:48:46.159
It doesn't matter.
01:48:46.399 --> 01:48:51.600
No, no, the way we do it at the same time is that when he says that we'll say, that's when you have to say happy array programming.
01:48:51.760 --> 01:48:57.680
Yeah, yeah, but back in the day, in the old days, it was he'd say it and then everyone would say it.
01:48:57.760 --> 01:48:58.000
Yeah.
01:48:58.159 --> 01:49:00.800
And if we didn't even say, that's because you would fix it in post.
01:49:01.840 --> 01:49:03.359
But now we're live, things are different.
01:49:03.680 --> 01:49:04.640
Anyways, thanks guys.
01:49:04.720 --> 01:49:06.319
We'll uh we'll do this again sometime.
01:49:06.640 --> 01:49:07.039
All right.
01:49:07.680 --> 01:49:08.560
Great to see you.
00:00:12.320 --> 00:00:16.320
Welcome to ArrayCast episode 125.
00:00:16.719 --> 00:00:23.359
I am your host, Connor, and I'm here today with the only panelist, therefore co-host for the time being.
00:00:23.600 --> 00:00:33.600
Adam, I guess we'll go around just for old time's sakes and do brief introductions, and then we've got two announcements, and we've got hopefully a fun topic, maybe a little bit different because we've got this YouTube format.
00:00:33.679 --> 00:00:36.880
But before we get to that, uh we'll do a brief introduction from Adam.
00:00:37.280 --> 00:00:38.799
Right, I'm Adam Botsewski.
00:00:39.119 --> 00:00:41.359
Um I've been doing APL my whole life.
00:00:41.520 --> 00:00:48.880
I I do APL at Dialog Limited, where we create the APL of the future, I could say.
00:00:48.960 --> 00:00:57.359
And I'm I've been honored to become the head of language design there, but I also deal with everything else dealing with the language at dialogue.
00:00:57.679 --> 00:01:02.960
And as always, I am your host, Connor, massive fan of all the array languages.
00:01:03.280 --> 00:01:07.680
And yes, we have two announcements I day, uh I believe today, both from Adam.
00:01:07.760 --> 00:01:10.719
So I'll throw it over to you and then we'll hop into our conversation.
00:01:12.079 --> 00:01:30.400
Um right, so I unfortunately had to announce in the last episode that uh Kitty Christensen, the former CEO and uh um of Dialic Limited, and much of the reason that we've been here today, uh passed away, uh, there was a uh a funeral service for her.
00:01:30.640 --> 00:01:42.480
And there's also been set up a uh a memorial site where you can both uh see a lot about her and uh bituary and and other things, but you can also add your own tribute.
00:01:42.640 --> 00:01:44.239
I'm sure that a lot of people want to do that.
00:01:44.640 --> 00:01:46.799
So it's gittercrestens.
00:01:48.799 --> 00:01:51.120
And we'll leave a link to that as well.
00:01:51.840 --> 00:02:16.479
And then uh there is the APL Forge, which is uh the thing we do a dialogue every once a year, um where we let people submit um projects that you started in or for dialogue APL, and it comes to an end once a year, and then we start a new round, and there's one month left of this year until we stop at the round and there's the next round.
00:02:16.560 --> 00:02:30.879
And you can still if you have some kind of cool thing you made in APL, um then you can uh still um submit it and then we'll have a look at it, and you might win a price and um a trip to the next user meeting.
00:02:31.120 --> 00:02:33.759
So have a look at uh forge.dialog.com.
00:02:34.000 --> 00:02:37.439
And we will have links for everything that just got mentioned in the show notes.
00:02:37.599 --> 00:02:43.199
And surprise, surprise, we have now a second panelist, or technically guest.
00:02:43.280 --> 00:02:48.639
I mean, you are listed on raycast.com as a recurring panelist, so I guess you are a panelist for today.
00:02:49.120 --> 00:02:49.680
How's it going?
00:02:50.879 --> 00:02:52.800
It's not bad, it's not bad, kind of thanks.
00:02:52.960 --> 00:02:57.599
You're popping into a live stream on YouTube, so I'm not sure if you've heard, but things are things are different now.
00:02:57.680 --> 00:03:00.080
You know, there was the before era, now there's the after era.
00:03:00.319 --> 00:03:04.639
And in this after era, uh we just uh You just go straight there.
00:03:04.879 --> 00:03:18.319
Yeah, it's mostly laziness, I guess, because Bob was doing a lot of work back in the before era in a raycast 1.0, and Adam and I wanted to keep on keeping on, but I did not have the time to uh put the amount of effort that Bob put in.
00:03:18.400 --> 00:03:20.479
So we said, What uh I thought to myself, what's the easiest way?
00:03:20.560 --> 00:03:29.919
And I was like, wait, in Tacitalk, I just live stream, I do a little bit of post-processing, and if AI gets good enough, maybe it'll actually it'll never reach Bob levels.
00:03:30.080 --> 00:03:34.479
But you know, maybe the ums will get removed and the the dead air will get removed.
00:03:34.719 --> 00:03:37.680
And uh, anyways, um it's good to have you here.
00:03:37.840 --> 00:03:40.319
And in the chat, we've got uh multiple hellos.
00:03:40.560 --> 00:03:45.039
Well, one person saying hello to the chat, but also Max, aka meme god, saying, Wow, it's rich.
00:03:45.120 --> 00:03:48.560
You know, he's uh Is that Max?
00:03:48.719 --> 00:03:49.280
Sorry?
00:03:50.000 --> 00:03:53.599
I saw him not long ago, so yeah in in real life.
00:03:53.680 --> 00:03:54.719
So hello again.
00:03:54.960 --> 00:03:56.400
I also saw him not long ago.
00:03:56.479 --> 00:04:00.800
I mean, he's local to Toronto, so I guess it's probably easier for me to see him than it is for Right.
00:04:00.879 --> 00:04:02.639
I had to fly a long way.
00:04:03.919 --> 00:04:08.479
All right, well, you joined just in time uh for a little bit of a different episode.
00:04:08.560 --> 00:04:11.439
So Rich, I guess, has no idea what's about to happen.
00:04:11.680 --> 00:04:22.160
And um, Adam got, I believe, if you include the time when he was reading the announcements and introducing himself, a grand total of like 10 minutes to ruminate about this problem.
00:04:22.240 --> 00:04:29.120
But we're gonna uh chat about a toy trivial uh problem from Pearl Weekly Challenge.
00:04:29.199 --> 00:04:30.720
We actually don't know the number.
00:04:30.959 --> 00:04:39.439
If for whatever reason this gets back to the Pearl Weekly Challenge people, uh you clearly vibe coded, which I've got nothing, I'm I'm a big vibe coder.
00:04:39.519 --> 00:04:47.279
Uh I love vibe coding, but they vibe coded an upgrade to their Pearl Weekly Challenge website, and it is no longer clear to me.
00:04:47.439 --> 00:04:50.560
I mean, I spent like three minutes, that's why we were a bit late starting this episode.
00:04:50.639 --> 00:04:55.680
I mean, the podcast people and the audio players have no idea that we were three minutes late, but the folks on YouTube know.
00:04:55.759 --> 00:04:59.759
And we couldn't find the the past uh problem links.
00:05:00.000 --> 00:05:07.279
Anyways, I happen to recall the problem from memory, so this was in the last like month or two though, and I never actually solved this problem.
00:05:07.680 --> 00:05:13.040
I read it, I thought about it, and then I couldn't find an or think of an elegant way to solve this.
00:05:13.199 --> 00:05:21.839
It's definitely solvable quite easily, but like I couldn't think of a kind of single one-liner tacit solution because there's a kind of a couple edge cases.
00:05:22.000 --> 00:05:22.800
So here's the problem.
00:05:22.879 --> 00:05:28.720
And I'm not sure if at some point uh I want to share my screen or screen or Adam wants to share his or Rich, you can even share yours.
00:05:28.959 --> 00:05:32.319
I'm on the table of problems now on the on the weekly challenge site.
00:05:32.399 --> 00:05:33.839
So once you describe it, I think.
00:05:34.160 --> 00:05:39.680
Does it is it the one that says recap, or is there like a link to because the recap one just No no slash challenges?
00:05:39.839 --> 00:05:43.839
So it funnily enough, in the title bar, it's under the tab this week.
00:05:44.000 --> 00:05:46.560
So that's the one I went to.
00:05:46.720 --> 00:05:47.600
That's the one I went to.
00:05:47.839 --> 00:05:50.800
And then I would think, oh, it's just for this week, it's actually past weeks.
00:05:50.959 --> 00:05:53.680
But when you click on recap, it doesn't bring you to the problem statement.
00:05:53.759 --> 00:05:55.759
It just shows you how many languages it was solved in.
00:05:56.000 --> 00:05:56.560
Oh, I see.
00:05:56.720 --> 00:05:57.759
No, no, I'm not that far.
00:05:57.839 --> 00:05:59.120
I'm just at the table of Yeah.
00:05:59.360 --> 00:06:04.319
Look at that though, like the UI experience here, two different people completely unrelated, did the exact same thing.
00:06:04.399 --> 00:06:08.319
They they found the challenges under this week, thought that's a weird place to put it.
00:06:08.480 --> 00:06:13.040
And then it turns out uh, first of all, it's not for this week, it's for the past weeks, but it doesn't actually show the problem description.
00:06:13.439 --> 00:06:16.319
It's an abbreviation for this and all weeks.
00:06:16.720 --> 00:06:18.240
Yeah, obviously.
00:06:18.480 --> 00:06:20.000
Uh go on, describe the problem.
00:06:20.079 --> 00:06:20.560
We'll we'll see.
00:06:20.879 --> 00:06:41.439
So the problem is, and it may be someone in the YouTube chat, because we've got a few viewers, um, and and play along as well if you're on YouTube doing this live, and also if you're listening to this in Spotify, Apple Podcasts, whatever player you use, you're given a string of lowercase characters, and you want to return the largest distance between two equal characters.
00:06:41.600 --> 00:06:43.439
So two characters that are the same.
00:06:43.680 --> 00:06:52.480
And if there are no duplicate characters, so there's no two characters to find a large distance between, uh, it is you return negative one.
00:06:52.800 --> 00:06:55.600
And you it's exclusive of those two characters.
00:06:55.680 --> 00:07:07.519
So the easiest example is, or a couple examples, if you have the string A, B, C, C, B, A, the two characters that have the largest distance between them are the a at the beginning of the string and the a at the end.
00:07:07.680 --> 00:07:12.879
And because there's B C C B in between those, that's four characters, so the answer is four.
00:07:13.040 --> 00:07:20.560
If you have the string AABC, there are three pairs that all have the largest distance, which is zero.
00:07:20.720 --> 00:07:24.800
And if you have the string ABC with no duplicates, you return a negative one.
00:07:25.040 --> 00:07:29.040
And so if you want, we can ignore the negative one uh for a while.
00:07:29.199 --> 00:07:46.399
But even just the uh, you know, assuming that there is a duplicate, how to well actually I guess the negative one is the tricky part because if you were to do something like my uh my thought process, and then I'll let the pros uh step in, was that you want to use where or indices to do this.
00:07:46.639 --> 00:07:49.439
Um something, well, is that actually true?
00:07:49.600 --> 00:07:50.639
Or classify?
00:07:50.800 --> 00:07:58.879
I can't remember now that I I I guess I should have uh, but there's some operation basically where you want to get um well actually uh okay, I gotta step a step back.
00:07:58.959 --> 00:08:02.399
Let's actually walk through this if I'm solving this for the first time because clearly I've forgotten.
00:08:02.560 --> 00:08:04.959
I think at one point I was like, let's do an outer product.
00:08:05.040 --> 00:08:31.040
If you get a unique with the um values in your or the characters in your string, you can then get like a uh matrix where you have a mask that corresponds for ones for all equal values, and if you did an indices on that and then some kind of um you know two y's minus reduction, you could then get the differences, but then you're gonna run into issues with that.
00:08:31.279 --> 00:08:35.919
And then I I I think I had an alternate version with where, but it still wasn't great.
00:08:36.000 --> 00:08:55.039
And the problem is that if you are going to do the first last trick, so if you even if you take that matrix index idea and you look at the first value or the first index and the last index, you're not gonna get the correct value if you only have a single character in the case of the ABC string.
00:08:55.120 --> 00:09:00.159
Uh because the first and the last both point to the same one, and they can't both point to the same one, right?
00:09:00.240 --> 00:09:05.679
So you have to do some kind of check to make sure there's at least two indices that correspond to equal values.
00:09:05.840 --> 00:09:07.440
Um and yes, someone in the chat.
00:09:08.159 --> 00:09:09.519
That's just checking.
00:09:09.759 --> 00:09:14.080
Like you know that that if they have the same if they have the same position, right?
00:09:14.159 --> 00:09:18.320
Because it's the f the first and left are the same, then the distance between them is going to be zero.
00:09:18.480 --> 00:09:22.960
So it's only a problem if there aren't any duplicates at all, right?
00:09:23.360 --> 00:09:23.679
Correct.
00:09:23.919 --> 00:09:26.639
Although now that's super easy to check.
00:09:27.200 --> 00:09:31.759
We have to subtract what I think is like a difference of zero already is invalid.
00:09:31.919 --> 00:09:33.919
Like it has to be a difference of yeah.
00:09:34.240 --> 00:09:39.120
So you just if there's if there's I mean, if this a just simply because a then the answer is zero, right?
00:09:41.360 --> 00:09:42.240
Are you still looking for it?
00:09:42.799 --> 00:09:43.279
Oh yeah, yeah.
00:09:43.440 --> 00:09:49.120
Uh some of the comments says straight oh largest same digits number, but I'm not sure it's that.
00:09:49.600 --> 00:09:50.480
Uh but hold on.
00:09:50.960 --> 00:09:53.360
Uh let that's just just to think about this.
00:09:53.519 --> 00:10:01.840
If if the string is aa, then the the first and the last indices, right, should be one apart.
00:10:02.000 --> 00:10:03.840
But the actual answer we should give is zero.
00:10:04.240 --> 00:10:05.440
So we just subtract one, right?
00:10:05.519 --> 00:10:05.679
Right.
00:10:05.759 --> 00:10:06.080
And then the one that's a little bit different.
00:10:06.240 --> 00:10:12.799
Now the only way to get the only way to get the largest distance being zero if if every character is unique.
00:10:13.039 --> 00:10:16.799
So all we need to do is subtract one and then we get negative one.
00:10:17.039 --> 00:10:18.000
Isn't that super easy?
00:10:18.480 --> 00:10:18.879
That's so sad.
00:10:18.960 --> 00:10:19.440
Yeah, yeah, yeah.
00:10:19.600 --> 00:10:30.960
So this corner case that I thought made it tricky, it's actually super simple because you're gonna have to subtract one from everything, and the case where it's zeroed actually gives you the exact value that you need.
00:10:31.360 --> 00:10:34.879
So I think that I have a solution in in dialog API.
00:10:34.960 --> 00:10:35.919
If you want me to share my screen.
00:10:36.159 --> 00:10:36.559
Yeah, yeah, yeah.
00:10:36.960 --> 00:10:40.080
And so there was someone in the chat that was mentioning a different problem.
00:10:40.240 --> 00:10:41.759
It definitely wasn't that problem.
00:10:41.919 --> 00:10:51.120
Uh and yes, we were saying that we pro weekly challenge recently vibe coded their an upgrade to their website, and we can't find a list of the last problems.
00:10:51.279 --> 00:10:58.159
The hack that I was doing is if you go to this week, it shows you a full URL with uh weekly or week 374.
00:10:58.559 --> 00:11:05.600
If you just change those URLs to 373, 372, 371, which is what I was doing, but I couldn't figure out.
00:11:05.759 --> 00:11:08.320
Um, I still couldn't find the exact problem statement.
00:11:08.399 --> 00:11:09.600
But it was in the last month or two.
00:11:09.679 --> 00:11:15.120
So if you uh you know YouTube viewers want to go and try and find the link, paste it, we will we will then share it with folks.
00:11:15.279 --> 00:11:16.480
Uh we don't know which week this is.
00:11:16.799 --> 00:11:21.279
I was immediately thinking uh Adam's sharing a screen and it's got the the key operator.
00:11:21.360 --> 00:11:24.879
As soon as you described the problem, I was immediately thinking key in my head.
00:11:25.200 --> 00:11:34.960
Um where the default gives you the indices where unique major cells and in this case unique elements occur.
00:11:35.039 --> 00:11:37.039
And that's that's what you're concerned with, right?
00:11:37.120 --> 00:11:38.879
So the indices of elements.
00:11:39.279 --> 00:11:57.039
Yeah, well, I was concerned that if you like, like I said, like it's actually ironic that I thought this one was tricky because the problem statement actually is perfect in that getting the negative one is a natural byproduct of actually subtracting one from the deltas between the indices.
00:11:57.279 --> 00:12:06.480
So like what I thought, and I thought that was the tricky part because you had to deal with that some way, but it's actually it falls out of just dealing with the the general case.
00:12:06.720 --> 00:12:14.320
And uh the interesting thing is though that both of you thought of key, whereas I guess I don't reach for key rarely ever.
00:12:14.480 --> 00:12:16.159
I always think about I don't know.
00:12:16.480 --> 00:12:17.279
Doesn't do a lot of groups.
00:12:17.440 --> 00:12:19.360
You basically said it, you said classify, right?
00:12:19.600 --> 00:12:23.200
Yeah, you said classify, and that is what it does.
00:12:23.519 --> 00:12:29.120
Classify is not an APL though, so this is it fulfills the same role, right?
00:12:29.200 --> 00:12:31.600
It takes these and puts them into takes all the A's.
00:12:31.759 --> 00:12:39.840
So the way I thought it was key anyway, because we're not interested in A in relation to any other letter than A.
00:12:40.000 --> 00:12:47.600
So classify was that the once upon a time a monadic equals in some writings that would give you that matrix.
00:12:47.679 --> 00:12:48.320
It's like a character.
00:12:48.879 --> 00:12:50.320
Yeah, things matrix.
00:12:51.279 --> 00:12:51.840
Yeah, okay.
00:12:51.919 --> 00:12:52.240
Yeah.
00:12:52.559 --> 00:12:54.000
So this is exactly what I said, right?
00:12:54.080 --> 00:12:58.240
I said, yeah, like a unique uh this is what they had to do before key.
00:12:58.480 --> 00:12:59.679
Ease before key.
00:13:00.159 --> 00:13:00.399
Yeah.
00:13:00.720 --> 00:13:10.320
So actually, so let's this is amazing, but we uh like I'm very excited because this is I you know, uh did we have a topic for today, you know, uh Adam and I were trying to figure out, and I was like, well, what are you talking about?
00:13:10.559 --> 00:13:18.639
I know, I know, but I thought in my head, I was like, well, there's not anything like topical news or and we didn't have time to set up a guess because I've been I've been out of the country for the last uh week.
00:13:18.799 --> 00:13:27.120
But I was thinking, you know what I actually want to do is I want to ping, I want to I want Adam to solve this problem that I like in my head a month ago couldn't like come up with an elegant solution for.
00:13:27.200 --> 00:13:31.279
And now we've got like three different solutions, or at least two.
00:13:31.440 --> 00:13:39.279
Uh, but let's so let's take a step back and walk people through the uh the first uh and so someone I think has found it.
00:13:39.519 --> 00:13:50.639
Task two, they haven't mentioned the day, but the exact wording of the problem is you're given a string, write a script to return the length of the largest substring between two equal characters, excluding the two characters.
00:13:50.799 --> 00:13:53.279
Return negative one if there is no such substring.
00:13:53.440 --> 00:13:57.840
So I I stated it slightly differently, but it was just an alternate description of the same problem.
00:13:58.960 --> 00:14:02.480
The only problem is if it's empty, then things will end up.
00:14:02.639 --> 00:14:06.159
D Z and Naroli, if you'd like to say what week that was.
00:14:06.320 --> 00:14:09.120
Um yes, that is the exact problem that we are talking about.
00:14:09.200 --> 00:14:14.399
If you say the week, we will uh we will mention it for the audio listeners, obviously everyone on YouTube at this point.
00:14:14.559 --> 00:14:18.960
So yeah, walk us through starting with key, because I'm sure there's people in the chat.
00:14:19.039 --> 00:14:23.840
Uh because like I said, I I rarely reach for key, but it is in this case exactly what you wanted.
00:14:24.080 --> 00:14:26.240
Yeah, so let's take this this simple example here.
00:14:26.399 --> 00:14:30.639
We've got uh ABCAA uh with key.
00:14:31.039 --> 00:14:37.600
And uh we're just going to inspect what uh what the elements are going uh are going to be.
00:14:37.759 --> 00:14:41.519
So the way it works is the key uh what the argument is going to be.
00:14:41.679 --> 00:15:06.879
Um the key will classify well, it will it will take the col the um array on the right as a collection, and it will punch together all the equal elements, and it will call the function on its left with that element uh or that um that major cell really uh as left argument, and the right argument is going to be the list of indices where those appear, right?
00:15:07.120 --> 00:15:12.320
So we see A appears at these places, b at these places, c at these places.
00:15:12.559 --> 00:15:16.720
Now we're not actually interested in the element itself, so we can get rid of that.
00:15:16.799 --> 00:15:30.720
We're just interested in the in the indices of individual um elements, and then we wanted to find the location of the uh uh the largest and the the first one and the last one, and then subtract them.
00:15:30.799 --> 00:15:35.919
So this is the so the max reduction and the min reduction, and subtract the two.
00:15:36.320 --> 00:15:37.759
Wow, you walk people through that.
00:15:38.000 --> 00:15:41.279
I assume they uh know a little of AP, but they're shocked by you.
00:15:41.600 --> 00:15:44.080
Whoa, what is this incantation that you managed to okay?
00:15:44.159 --> 00:15:44.960
So this is the fork.
00:15:45.200 --> 00:15:48.399
So this is the the maximum reduction on the list.
00:15:48.559 --> 00:15:58.480
This gives the last time anything appears, and this is the uh minimum reduction, so the first time it appears, which could be the same, of course, if there's if there's only one.
00:15:58.799 --> 00:16:06.080
And to be clear, the reason you're saying first and last is because a property of these indices is that they're gonna be sorted.
00:16:06.399 --> 00:16:08.879
Uh yeah, of course they're in there, they're sorted, they're sorted there.
00:16:09.039 --> 00:16:12.159
But it doesn't matter, even if they weren't sorted, I'm actually not getting the first and last.
00:16:12.240 --> 00:16:14.960
I'm actually getting the maximum and minimum.
00:16:15.039 --> 00:16:16.720
So I can actually make this shorter matter.
00:16:17.279 --> 00:16:24.080
It's the maximum min glyphs, but you were saying first and last, which yeah, it's going to be the if you're not staring at the screen.
00:16:24.240 --> 00:16:28.240
Uh you could also in a moment for that reason.
00:16:28.399 --> 00:16:29.919
Uh what do you say, Richard?
00:16:30.159 --> 00:16:32.799
You could use first and last in this case for that reason.
00:16:33.039 --> 00:16:34.879
Yeah, it's just it's but it's sorted.
00:16:35.200 --> 00:16:44.000
It's easier to reason about it like this, but but we can change it to then and we don't have a math if you're gonna do first and last because it wouldn't be able to compute anything.
00:16:44.240 --> 00:16:44.720
That's true.
00:16:44.960 --> 00:16:46.240
We can go half later.
00:16:46.399 --> 00:16:47.679
Well woo, half later.
00:16:47.840 --> 00:17:02.639
Uh okay, so and and what happened over here is basically just in mathematics that if you've got uh f of x plus uh g of x, then you're allowed to write that as f plus g of x.
00:17:03.120 --> 00:17:04.880
So I use that over here.
00:17:05.039 --> 00:17:11.920
So this is the the max of the right argument minus the uh min of the argument.
00:17:12.160 --> 00:17:16.079
So that's what's happening here, and that gives us that gives us these.
00:17:16.160 --> 00:17:19.440
Uh we don't actually need the enclose anymore because they're all scalar values.
00:17:19.599 --> 00:17:35.839
Um and then we wanted to uh subtract one, so because we consider adjacent as having a string of length zero between them, so that gives us all these, and then we want to find the maximum value, and if there are only negative ones, of course it becomes negative one.
00:17:36.160 --> 00:17:41.599
So this is the this is the full solution, and this can be written locally in a tacit way as well.
00:17:41.839 --> 00:17:45.839
Uh so we can try that, and then we can try it on these.
00:17:48.480 --> 00:18:00.319
Um and now because these are max, I mean actually they're actually sorted, we can replace the in the in Dalegap, we can replace the minimum with the first cliff, which is fine.
00:18:00.480 --> 00:18:02.960
Uh it doesn't really matter.
00:18:03.440 --> 00:18:06.880
Um And there's some more things we can do.
00:18:07.039 --> 00:18:18.160
We can because this is just applying a function on the argument, but we had it has to be the right argument, so we can just say that we apply we composing these at the top.
00:18:18.319 --> 00:18:26.079
So we say we want this function applied to the result of uh the function that selects the right argument, it can also the left argument.
00:18:26.400 --> 00:18:28.559
So that's this also works.
00:18:28.880 --> 00:18:32.640
Uh it would be so nice if we had a last glyph, wouldn't it?
00:18:34.319 --> 00:18:35.839
Maybe later we'll I'll solve this.
00:18:35.920 --> 00:18:48.559
Well, I'll attempt to solve this in Tiny Apple because not only do they have uh yeah, the first and last, but they also have I believe Classify, which there's yeah, uh Rich is in the chat.
00:18:48.640 --> 00:18:49.920
I was also thinking the same thing.
00:18:50.000 --> 00:18:55.920
So Max has said that IOTA self uh is classify in BQN or swap.
00:18:56.079 --> 00:19:02.079
I'm not sure which one it is, but Iota is um not in uh BQN.
00:19:02.240 --> 00:19:15.519
They have the range glyph, but I'm pretty sure classify is actually one of like the I can never remember, but they they have like the claws or like the open boxes on their sides and the underbar open boxes on their sides.
00:19:15.759 --> 00:19:17.759
One of those I'm pretty sure is classify.
00:19:18.079 --> 00:19:20.480
And in fact, yeah, this is classifying, right?
00:19:20.640 --> 00:19:23.599
That that's the I think that's what theme god is trying to say.
00:19:25.279 --> 00:19:31.680
So here I'll put in the I'm not sure if uh the uh so you want to you want to group by the classif self-classification here, right?
00:19:32.079 --> 00:19:39.200
Um that's another way another way to get the the indices here, but uh but key is of course very nice.
00:19:40.720 --> 00:19:52.880
So there is a participant in the chat with a name that I find difficult to pronounce, spelled underscore underscore dash kd eight o z or is it e depending on the s.
00:19:53.279 --> 00:19:54.240
We'll just call them ours.
00:19:56.160 --> 00:19:57.359
Kd eight oz.
00:19:57.759 --> 00:20:11.200
Um uh and uh try to translate it to J that looks to to a j solution that we can I can put here in the just paste it in yesj if we were on Ray Box we could actually evaluate it.
00:20:11.440 --> 00:20:16.720
But I this seems overly overly complicated because J has key.
00:20:16.880 --> 00:20:21.759
Now I'm not an expert on using it, but so wait, wait, let's walk because this is exactly this is interesting, right?
00:20:21.839 --> 00:20:35.839
This was the and we're gonna solve this in dialogue APL this way as well, because you before I said let's slow down and walk people through the first solution, you showed the unique without a product, and the next step would be to do like an indices on each of the rows.
00:20:36.079 --> 00:20:40.160
And my j foo is not great, but basically that's what that looks like, right?
00:20:40.240 --> 00:20:41.680
You've got a I yeah.
00:20:41.759 --> 00:20:49.839
So if we do if we do like a unique um the U Oz just said uh it's a randomly generated name.
00:20:50.319 --> 00:20:51.680
Don't let it befuddle you.
00:20:51.759 --> 00:20:53.920
And the thing is that I don't know how to use key and j.
00:20:54.079 --> 00:20:55.039
So here we go, folks.
00:20:55.200 --> 00:20:59.200
We're taking key and j for a spin, although we're still in dialogue EPL.
00:20:59.279 --> 00:21:00.400
So we'll we'll get dialogue.
00:21:01.599 --> 00:21:09.440
If you do the indices here for these, so we want each row, we want to do the max index and the min index, right?
00:21:09.599 --> 00:21:11.839
That would that would work as well.
00:21:12.000 --> 00:21:13.759
So we can s we can try this.
00:21:13.839 --> 00:21:31.599
So on each row, we want to get uh the uh the index of the la uh well, so we want the indices and then we want the max minus minus the min, which is of course the first and the last, the same thing.
00:21:32.079 --> 00:21:32.720
Like this.
00:21:33.119 --> 00:21:36.400
So that then we're up to the step and we can continue from there.
00:21:36.880 --> 00:21:46.000
Can't you I guess right, you don't have but technically you don't have uh cells, like you don't have a shortcut for rank one.
00:21:46.480 --> 00:21:48.319
No, but it wouldn't help much either.
00:21:48.640 --> 00:21:48.799
Right.
00:21:48.880 --> 00:21:52.640
I was I was gonna say I was thinking is there some way to do the shorter, but I think this probably is the short.
00:21:53.440 --> 00:21:58.720
There is because you can you could do you can do trickery with nested arrays, we can do this, right?
00:21:59.039 --> 00:22:10.640
Because of how Net how um scalar functions penetrate into structure, so then we make the whole thing a scalar, and then we get the unique, which is another vector.
00:22:10.720 --> 00:22:14.240
So vector equals scalar, it gets the whole scalar gets paired up with each one.
00:22:14.319 --> 00:22:15.920
So now we've got these three, right?
00:22:16.000 --> 00:22:23.440
So those are just the rows of this same thing as splitting this into its constituent cells, and now the rank one has magic.
00:22:23.519 --> 00:22:25.440
You just you just blew through this.
00:22:25.599 --> 00:22:30.720
Whoa, so now we can just do an each on this instead, and we get the same thing.
00:22:30.799 --> 00:22:32.400
So that's slightly shorter.
00:22:33.279 --> 00:22:39.279
So step back to uh so you've got in a fork unique equal enclose.
00:22:39.759 --> 00:22:43.680
Yeah, because if you think about it, if let's start with not unique.
00:22:43.920 --> 00:22:54.000
I'm thinking about it, but uh and and uh an identity function equals the in-close is so the in-close makes this whole thing into a single scalar, right?
00:22:54.079 --> 00:22:56.240
It's a nested scalar, but it's a single scalar.
00:22:56.559 --> 00:22:58.799
So now we've got vector equals scalar.
00:22:58.960 --> 00:23:05.839
I mean, so we know the result will be a vector where we take this entire scalar and pair it up with every element of the vector.
00:23:06.000 --> 00:23:09.680
Now the every element of the vector was those original letters.
00:23:10.160 --> 00:23:14.160
So we compare every letter with the entire vector.
00:23:14.319 --> 00:23:16.079
So that gives us this.
00:23:16.240 --> 00:23:21.200
This is the outer same thing as outer equality, but in a nested form instead of a rank form.
00:23:21.440 --> 00:23:29.759
And if we replace the density function with the unique elements, that's the same thing as the outer product, but in nested form.
00:23:30.079 --> 00:23:31.519
So this is that is beautiful.
00:23:31.599 --> 00:23:36.880
That's the same thing basically as a mix of the outer product that you have before, right?
00:23:37.119 --> 00:23:40.640
That's a split split split of this or mix of this, right?
00:23:41.519 --> 00:23:43.359
I can never uh I can never keep which ones.
00:23:43.839 --> 00:23:50.799
So a split of split splits it into individual uh rows and mix mixes together the rows into a single array, right?
00:23:50.960 --> 00:23:57.839
A single yeah, and technically you can put the split into the the tacit expression up there, and you can do the same thing.
00:23:58.000 --> 00:24:03.519
So really it's there's no point I know, but it's a two like if you want to assign these to a function.
00:24:03.839 --> 00:24:08.880
Oh actually, yeah, and then and but if you're and if you're golfing, this is basically like a two-character saving.
00:24:08.960 --> 00:24:13.440
So if you ever find yourself uh splitting uh oh right, then you can outer product.
00:24:14.240 --> 00:24:20.880
If you actually want the outer product, then it's shorter to write this than it is to write the equivalent, right?
00:24:21.039 --> 00:24:29.279
You save your one character, even though it's very silly, and it just looks beautiful, like the the rotated rotated horseshoe.
00:24:29.359 --> 00:24:35.200
Oh my god, the the the forks that look a bit like faces, yeah.
00:24:35.440 --> 00:24:36.160
I mean, I can't.
00:24:36.319 --> 00:24:39.680
I don't know if I can see an expression this guy, it's elegant as hell.
00:24:40.480 --> 00:24:44.079
Okay, so so and then we're just we just do the each here, right?
00:24:44.480 --> 00:24:46.880
Because now we have a nested form, we don't need to do rank one.
00:24:47.119 --> 00:24:59.759
So we essentially got the major cell cells for operator because now we're just operating on uh individual elements, and being that the result of this is a simple scalar, it all just collapses back.
00:25:00.319 --> 00:25:07.519
This wouldn't work in the in a boxed array model, but it does work here uh because of uh dialogue APL's floating arrays.
00:25:07.759 --> 00:25:09.519
But there's a there's more we can do actually.
00:25:09.599 --> 00:25:24.160
I was just thinking here because if we look at if we go back here and look at this, there's a fun thing that we actually just want uh the the largest one and subtract the first one.
00:25:24.559 --> 00:25:30.000
So uh what if we could find the position of the last one in a more direct way?
00:25:30.079 --> 00:25:33.519
And the position of the first so the position of the first one is actually interesting, right?
00:25:33.599 --> 00:25:34.720
Because that we find here.
00:25:35.279 --> 00:25:40.720
The position of the first A is one, the position of the first B is two, the position of the first C is three.
00:25:41.759 --> 00:25:44.880
So I mean it doesn't matter that we're doing the computation multiple times.
00:25:45.200 --> 00:25:48.000
How can we find the position of the last one?
00:25:48.079 --> 00:25:59.359
Well we can sort of do it by uh looking into into the reverse, but it's not quite, because then we get the position from the end instead.
00:25:59.680 --> 00:26:09.680
Okay, so so uh one is this one, and then then the B we find at position five, but from from the end.
00:26:10.000 --> 00:26:26.559
So if you subtract this from the the total length, then we can see that the last A is in position five, one, two, three, four, five, actually six, but off by one because we cut counting positions here compared to the um, but that doesn't matter so much.
00:26:26.880 --> 00:26:42.880
So this gives us the last position, and this gives us the first position, which means if we subtract the two, and then it will be the wrong uh the wrong uh sign, but that doesn't matter so much because we can easily just swap things around here.
00:26:43.279 --> 00:26:44.960
Oh sorry, did I do the wrong thing?
00:26:45.440 --> 00:26:48.079
Uh sorry, it should be like this instead.
00:26:48.799 --> 00:26:49.519
Is this right?
00:26:50.240 --> 00:26:52.000
Yeah, these give negative one, right?
00:26:52.079 --> 00:26:57.920
Because those are the ones that don't have any duplicates, and then we just want the largest uh value that we've got here.
00:26:58.480 --> 00:27:00.799
So one, two, three, four.
00:27:00.960 --> 00:27:02.400
That's the distance over here.
00:27:02.480 --> 00:27:04.960
So the the off by one error came to our advantage.
00:27:05.039 --> 00:27:06.400
We don't have to do that adjustment.
00:27:06.799 --> 00:27:12.000
So this is a this is a solution where we directly look for the first and the last, and we don't do the whole key thing.
00:27:12.160 --> 00:27:13.680
It's probably faster.
00:27:14.640 --> 00:27:21.359
In fact, we we wouldn't actually need to do it on all of them, we could just do it on the unique ones, but yeah, that's fine.
00:27:21.519 --> 00:27:22.640
Do you need to go through it again?
00:27:22.799 --> 00:27:23.839
See what just happened here?
00:27:24.160 --> 00:27:27.519
Well, and also this is only a solution for a subset of the problem, right?
00:27:27.680 --> 00:27:29.200
It doesn't handle the negative one case.
00:27:29.440 --> 00:27:29.920
Why not?
00:27:30.079 --> 00:27:32.079
You see, the negative one came out here.
00:27:32.319 --> 00:27:33.200
Yeah, because we come.
00:27:35.200 --> 00:27:38.640
I got three different selfie slash commute squiggles.
00:27:38.720 --> 00:27:41.039
This looks like absolute nonsense.
00:27:41.200 --> 00:27:43.519
Uh you you're the one that liked the combinators.
00:27:44.079 --> 00:27:44.400
No, I know.
00:27:44.480 --> 00:27:48.000
I say this from a place of combinator combinatory logic love, folks.
00:27:48.079 --> 00:28:06.960
I'm just saying we were we were dealing with the beautiful, unique equals enclose fork idiom that I just learned, and uh, I'm sure I could have used many times before, and then Adam was like, Oh yeah, well, hold my beer, and he was like, selfie, selfie, selfie, you know, and uh and then somehow had the right answer.
00:28:07.039 --> 00:28:07.839
Uh okay.
00:28:08.160 --> 00:28:10.079
Okay, so so here's the thing.
00:28:10.319 --> 00:28:11.839
Um, it just came out right.
00:28:11.920 --> 00:28:13.920
I hadn't planned it, it's just developing.
00:28:14.240 --> 00:28:18.079
But so this one you understand, this is sort of a classify thing, right?
00:28:18.319 --> 00:28:22.079
Because really, the dyadic iota, right?
00:28:22.240 --> 00:28:36.240
The index of has a built-in unique that we don't think about, but it's important here because what's actually happening is it only looks for the first position of any one element, so there's actually unique here, right?
00:28:36.400 --> 00:28:51.039
It's the only thing that's not this would give the same result if it's unique, but if we had like an F at the end, so we can't get rid of these, but they're not considered, nothing will ever give indices, there's nothing we put over here that will give indices four, five, six, right?
00:28:51.279 --> 00:28:54.799
I guess I the problem is I never use dyadic iota, I don't think for like anything.
00:28:54.880 --> 00:28:57.119
So I I don't even okay.
00:28:57.440 --> 00:29:01.519
And like in my mind, suboptimally, but like I just don't reach for dyadic iota.
00:29:01.680 --> 00:29:02.559
Uh okay.
00:29:02.640 --> 00:29:19.279
Well, I mean, we look we've we have real customers like at doing things, and APL has this huge toolbox of amazing things you can do, but I would say most applications out there they just look for information and retrieve information, don't like and then do a little bit with it.
00:29:19.440 --> 00:29:21.920
And looking for information, that's diet.
00:29:22.880 --> 00:29:25.279
Retrieving information, that's indexing.
00:29:25.440 --> 00:29:30.240
That's that's like 90% of what business applications do, looking things up and extracting it.
00:29:30.559 --> 00:29:38.160
Well, what is uh what is tiny apple because did tiny apple borrow um they borrowed the membership?
00:29:38.400 --> 00:29:41.839
Uh well I guess I can well I don't wanna but anyways, yeah.
00:29:42.160 --> 00:29:43.599
Anyway, let's let's let's go through this.
00:29:44.079 --> 00:29:44.880
I'll explain it.
00:29:45.039 --> 00:29:48.240
Okay, so index off it returns the first index off.
00:29:48.480 --> 00:29:50.720
Like it even exists in like JavaScript, there's an index off.
00:29:50.880 --> 00:29:52.559
That's dietic author, right?
00:29:52.880 --> 00:29:54.000
Uh sorry, say again.
00:29:54.240 --> 00:29:56.880
Say index off even exists in like JavaScript.
00:29:57.039 --> 00:29:58.960
And it's the same basically definition.
00:29:59.039 --> 00:30:01.759
The only difference is what if it's not found, but that doesn't matter here.
00:30:02.000 --> 00:30:04.400
Well, so I think the problem is that maybe that's this is what I'm thinking.
00:30:04.480 --> 00:30:10.960
Uh, because tiny apple has both index of and uh this one's called element of.
00:30:11.359 --> 00:30:15.359
And if those are the same thing and tiny apple has borrowed no, that's not the same thing.
00:30:15.599 --> 00:30:18.000
Element of is is is this, right?
00:30:18.079 --> 00:30:18.799
Oh, sorry.
00:30:18.960 --> 00:30:19.200
Right?
00:30:19.279 --> 00:30:20.319
That's if it's a member.
00:30:21.680 --> 00:30:27.599
Uh did you just type that, but it's not a member, it's not in uh dialogue APL membership?
00:30:27.839 --> 00:30:30.319
No, it's using uh new font.
00:30:30.480 --> 00:30:32.240
Okay, so this is no, so I okay.
00:30:32.400 --> 00:30:36.480
I'm not uh I was just trying to maybe think that like maybe I use it all the time but in a different language.
00:30:36.640 --> 00:30:39.039
But yeah, for whatever reason, I just don't use Diata Coyota.
00:30:39.200 --> 00:30:43.680
I don't know, I don't know why what I'm what I'm doing in the cases where you need it, but anyways, continue.
00:30:44.559 --> 00:30:46.880
We need to look up the position of something, right?
00:30:46.960 --> 00:30:48.960
So we're looking up the position of everything itself.
00:30:49.200 --> 00:30:59.200
So that's essentially has like a sort of a uh a nerfed unique inside because we only consider the the first time an element appears.
00:30:59.359 --> 00:31:03.519
So all the a's get mapped to position one that is there, right?
00:31:04.240 --> 00:31:07.759
So this so automatically this gives us the first position.
00:31:07.839 --> 00:31:16.079
I'm I'm using this property that I that's diadegayota will give us the first location of any one element to get the first locations of all the elements.
00:31:16.160 --> 00:31:22.400
So this is all these numbers are the first occurrences of all the elements, right?
00:31:22.640 --> 00:31:26.319
Then I want I want a variation on on diadega yota.
00:31:26.720 --> 00:31:30.880
I want the one that gives me the last position, but that's not built into the language.
00:31:31.200 --> 00:31:33.279
Then I'm constructing that piecemeal.
00:31:33.359 --> 00:31:34.720
So how can I find that?
00:31:34.880 --> 00:31:39.599
Well, let's say we start by uh by reversing instead, right?
00:31:39.839 --> 00:31:44.480
So if we reverse, then we're looking up, think of this one as being reversed.
00:31:44.559 --> 00:31:50.079
So we're so this is position one, f, this is position two, this is position three, and so on.
00:31:50.559 --> 00:31:52.799
So a gets mapped to two, okay.
00:31:53.039 --> 00:31:54.480
F A, right?
00:31:54.799 --> 00:31:57.839
And b gets mapped position six because we're counting from the right.
00:31:58.160 --> 00:32:03.440
But we can't compare indices counting from the left with indices counting from the right.
00:32:03.599 --> 00:32:07.759
So how do you how do you swap which direction an index is counted from?
00:32:08.160 --> 00:32:13.839
You do that by subtracting them from the total length, and then you have an off by one error, but I'm not worried about that.
00:32:14.559 --> 00:32:22.160
So basically, position five from the end is position length minus five from the beginning.
00:32:22.480 --> 00:32:23.200
Are you with me?
00:32:23.359 --> 00:32:25.920
Yeah, okay, so that's exactly what I'm doing.
00:32:26.079 --> 00:32:30.079
So we'll take these numbers and we'll subtract them from the length.
00:32:30.160 --> 00:32:32.880
So we'll take the string again and subtract.
00:32:33.039 --> 00:32:35.440
Okay, this is the position from the beginning.
00:32:35.680 --> 00:32:40.240
So the f the last a is in position five, except we have an off by one error, but that doesn't matter.
00:32:40.480 --> 00:32:43.599
Position one, two, three, four, five.
00:32:43.680 --> 00:32:44.720
So yeah, off by one.
00:32:44.880 --> 00:32:47.359
But since it's consistent, I'm not worried about it at this point.
00:32:47.599 --> 00:32:51.680
Really, we want because of fence post, whatever, we want to add uh add one.
00:32:52.160 --> 00:32:54.559
These are zero indexed now.
00:32:55.119 --> 00:32:56.079
Okay, great.
00:32:56.640 --> 00:32:59.440
So we have the indices here.
00:33:00.240 --> 00:33:03.519
And we do uh actually it's the other way around, but it doesn't matter.
00:33:03.680 --> 00:33:06.720
So we're subtracting the last position, right?
00:33:06.799 --> 00:33:09.440
So sorry, we're subtracting the first position from the last position.
00:33:09.519 --> 00:33:13.359
That's why I'm commuting the the minus, and that gives us these numbers.
00:33:13.440 --> 00:33:20.480
And luckily, we needed to we're off by one, but we needed to subtract one anyway for the problem statement, so it all works out, just happens to be.
00:33:20.640 --> 00:33:24.880
And from here on, everything is like we did before, we just need the max value.
00:33:25.200 --> 00:33:26.240
So all good.
00:33:26.400 --> 00:33:29.599
Now, of course, this is longer than this.
00:33:29.680 --> 00:33:32.240
So I'll just show you how we how we get there.
00:33:32.480 --> 00:33:35.759
Okay, so everything notice that this works out very nicely as a train.
00:33:35.839 --> 00:33:41.839
Immediately we can see that because uh we've got a bunch of functions and all the arguments are the same, right?
00:33:42.079 --> 00:33:46.160
So if we try to first define this as a def and nothing, then it makes it easier to see.
00:33:47.279 --> 00:33:47.519
Right.
00:33:47.599 --> 00:33:49.920
So we'll let's let's just do that down here.
00:33:50.160 --> 00:34:06.960
We'll put the argument uh out over here and replace them with omega so we can because annotation is really important, and being able to just spot the patterns much easier if you have a symbol than if you have a whole uh distracting uh string.
00:34:07.599 --> 00:34:11.519
Okay, get rid of all those pesky spaces because they're also just distracting.
00:34:11.840 --> 00:34:13.199
Okay, so all good.
00:34:13.280 --> 00:34:13.679
This works.
00:34:13.840 --> 00:34:15.599
We can even try it with all our test cases.
00:34:15.679 --> 00:34:23.039
We do it on this one, we do it on the ABC one, and we do it on the one with like the all the JSON necklace, right?
00:34:23.440 --> 00:34:25.519
Shouldn't this give zero by the way?
00:34:25.840 --> 00:34:27.679
Uh no, no, I think that's right.
00:34:27.760 --> 00:34:30.639
It's uh it's the still yeah, it's why there's one in between.
00:34:30.719 --> 00:34:31.840
Yeah, it's not AA, right?
00:34:32.000 --> 00:34:37.199
It's just uh yeah, we can do one more that's Rich with the save with the save there, Rich.
00:34:37.360 --> 00:34:37.920
I like that.
00:34:38.400 --> 00:34:39.519
I was also thinking the same thing.
00:34:39.599 --> 00:34:44.239
I was like, oh yeah, yeah, because I changed the case one before it wasn't AA, right?
00:34:44.400 --> 00:34:45.760
Okay, so now we go through this.
00:34:45.840 --> 00:34:47.440
So this one is a selfie, right?
00:34:47.519 --> 00:34:48.639
You should you spot that.
00:34:48.880 --> 00:34:51.119
So this isn't a commute, this is actually a selfie.
00:34:51.360 --> 00:34:52.159
We'll do that.
00:34:52.320 --> 00:34:59.599
This is the length, we leave that for now, and this this pattern is exactly the new thing in version 20 of dialogue, right?
00:34:59.679 --> 00:35:01.280
We with the behind operator.
00:35:01.599 --> 00:35:04.320
Sigma combinator, and this favor.
00:35:05.039 --> 00:35:07.360
So we can type this like this, okay?
00:35:07.440 --> 00:35:08.800
So this is our next step.
00:35:08.880 --> 00:35:19.039
I should give the same thing, and at this point, we're basically ready to go to go test it because we we now have one, two, three functions that are uh applied to the argument.
00:35:19.199 --> 00:35:24.960
We have got intervening functions with them here, and then we got an atop with the last one, which just works out beautifully.
00:35:25.119 --> 00:35:29.199
So get rid of that one, get rid of this one, I'll get rid of the parentheses later.
00:35:29.760 --> 00:35:30.960
There we there we go.
00:35:31.119 --> 00:35:34.559
And now we get rid of the parentheses like that.
00:35:34.800 --> 00:35:35.119
Yeah.
00:35:35.599 --> 00:35:37.440
Max has a great suggestion.
00:35:37.599 --> 00:35:39.360
Can you uh inline trace?
00:35:42.800 --> 00:35:45.679
I'm interested to see how uh whether this clarifies enough.
00:35:46.000 --> 00:35:48.719
So this is the new inline tracing in version 20.
00:35:48.960 --> 00:35:54.320
Uh, we can make this a bit bigger so we can see that there's this is the argument in array notation.
00:35:54.719 --> 00:36:00.480
And so we this is the function here, and it's being given this right argument.
00:36:00.719 --> 00:36:07.280
Uh we're now stepping into it, it's parsing through this basically, step by step of the train that's working so far.
00:36:07.519 --> 00:36:10.239
Stepping into this, which is just a derived function.
00:36:10.480 --> 00:36:14.159
Finally, we're going to remember it's it's behind.
00:36:14.239 --> 00:36:21.519
So first we apply the reverse on this argument, and then we can say now this one is being applied dyadically, so it opens the window over on the left.
00:36:21.679 --> 00:36:23.039
It's working beautifully so far.
00:36:23.199 --> 00:36:37.440
So now we're looking up the right direction array into its reverse, and uh then we are applying the um the length here, doing the subtraction, seven minus all these indices we computed before.
00:36:37.840 --> 00:36:45.679
Then we go find the selfie, we step into that, so we can see that's the same argument being applied twice with the right and left arguments of iota.
00:36:46.320 --> 00:36:57.440
That gives us all the selfie uh indices, and we subtract the uh um them from the indices we computed before, the last position ones.
00:36:57.760 --> 00:37:07.440
Uh we flip the arguments for the the commute, and then we have all the candidate numbers, and we take the greatest one and we can return.
00:37:07.599 --> 00:37:13.679
Uh not sure what this oh right now we're doing exactly the same thing on the second uh one because we do this in each, right?
00:37:13.760 --> 00:37:14.559
So we're stepping through it.
00:37:14.639 --> 00:37:32.079
I'm not going to actually go through the whole thing with with uh with all of them, but stepping in all the way, reverse, index of length, do the subtraction, the index selfie, and the subtract to get uh get all the candidates, and that's all negative ones.
00:37:32.159 --> 00:37:33.760
Okay, I'm just gonna step out of that.
00:37:33.920 --> 00:37:38.079
So I just think it was a great demonstration of using the inland tracing.
00:37:38.159 --> 00:37:38.960
Good call.
00:37:39.360 --> 00:37:41.119
All right, there's a bunch of things I want to see.
00:37:42.079 --> 00:37:44.639
Um how did this compare in length to the other solution?
00:37:45.039 --> 00:37:48.079
Can you put uh this original solution?
00:37:48.159 --> 00:37:49.679
It's I guess I stored as F.
00:37:49.840 --> 00:37:54.719
Now this new solution, and then also the indice were because then there was the one.
00:37:54.800 --> 00:37:55.840
Wow, actually, which one?
00:37:56.079 --> 00:38:00.880
There was the one just the one where we re-implemented key in terms of the outer product, right?
00:38:00.960 --> 00:38:03.039
There's no point that's what key is doing anyway.
00:38:03.280 --> 00:38:10.880
Well, so I want to I want to do the compare X on a like random string of 26 lowercase or like maybe a thousand lowercase.
00:38:11.519 --> 00:38:12.239
We can do that.
00:38:12.400 --> 00:38:15.599
Uh so this one, this one is F and this one is G.
00:38:15.840 --> 00:38:18.639
But we don't, I mean the outer product is going to be terrible.
00:38:18.800 --> 00:38:19.360
That's alright.
00:38:19.519 --> 00:38:20.400
We can do it if you want.
00:38:20.719 --> 00:38:21.039
That's okay.
00:38:21.199 --> 00:38:21.840
Should we do it?
00:38:22.079 --> 00:38:22.480
Nobody knows.
00:38:23.360 --> 00:38:24.880
I can't read which one do you want to do?
00:38:24.960 --> 00:38:26.800
The nested one or the the flat one?
00:38:27.119 --> 00:38:27.599
Let's do them both.
00:38:27.679 --> 00:38:28.320
Let's do them both.
00:38:28.400 --> 00:38:28.800
Let's have fun.
00:38:28.880 --> 00:38:30.000
Let's go wild, let's go crazy.
00:38:31.440 --> 00:38:37.039
And so while while Adam is putting this together, compare X, or um maybe there's there's like four different ways to spell it runtime, etc.
00:38:37.280 --> 00:38:37.440
etc.
00:38:37.760 --> 00:38:41.199
Is this beautiful thing that is in the dialogue APL REPL?
00:38:41.519 --> 00:38:45.199
Uh or I guess this isn't the REPL, this is the IDE or whatever you call it.
00:38:45.280 --> 00:38:57.920
But the you can basically inline profile things with like little Unicode boxes, and it's always a fun activity when you have multiple solutions to uh different problems uh to see which one is gonna be the best one.
00:38:58.159 --> 00:39:05.199
And I guess uh oh sorry, a couple uh comments send the role.
00:39:05.519 --> 00:39:11.519
I mean, yeah, it's a diadic iota is exactly oh, index in is what they call it in Wear, is that right?
00:39:11.760 --> 00:39:14.960
We call it index of, and then JavaScript has index of.
00:39:15.440 --> 00:39:18.000
Uh, but yes, that sounds like the same thing.
00:39:18.320 --> 00:39:18.960
Tubo.
00:39:19.440 --> 00:39:23.199
I want to add inline tracing to my own Lang, to my own language.
00:39:23.360 --> 00:39:26.719
How much would you say that the language design enables disables this?
00:39:26.880 --> 00:39:35.039
I mean it's just about whether you can pass things at runtime, isn't it?
00:39:35.280 --> 00:39:38.079
In order to have inline tracing.
00:39:38.960 --> 00:39:40.800
And also just uh FYI.
00:39:40.880 --> 00:39:45.679
Uh C4 Tubo is actually, I believe, I'm gonna kill myself if I get his name wrong.
00:39:45.920 --> 00:39:52.320
Chris from uh the Progue Lang Cast uh and Proguang Base YouTube channel and podcast.
00:39:52.559 --> 00:39:53.280
Oh, for real.
00:39:53.679 --> 00:39:55.599
Which we interviewed, right?
00:39:55.679 --> 00:39:56.960
On Eric Raycast?
00:39:57.519 --> 00:39:58.639
I'm almost positive we did.
00:39:58.800 --> 00:39:59.119
Christopher.
00:40:00.800 --> 00:40:01.360
Okay, got it.
00:40:01.599 --> 00:40:06.320
So you know you're getting old when you're like, uh, is my memory gonna work in this instance?
00:40:06.480 --> 00:40:13.199
Um and and the YouTube channel or YouTube channel, YouTube channel, podcast, all the same thing, I guess.
00:40:13.360 --> 00:40:17.440
They interviewed um Marshall one time, which was a great interview.
00:40:17.679 --> 00:40:23.039
Uh so, anyways, go check out the past uh Progline cast and ray cast episodes.
00:40:23.360 --> 00:40:29.440
Um and right here we got now uh Madeline Brigani, uh Tiny Apple.
00:40:29.519 --> 00:40:39.119
I was saying earlier in the podcast, I'm not sure if if you just joined live at this moment, Madeline, or you were listening at 2.0 XP to catch up.
00:40:39.360 --> 00:40:45.760
Um but I was I was wondering if Tiny Apple had Classify because I couldn't find it, but maybe it existed under a different name.
00:40:46.000 --> 00:40:52.320
Um but then also too, classify gives you that gives you the different indices, and actually, is that what you want?
00:40:52.480 --> 00:41:06.559
Because the different solutions we've looked at are you know you end up with the matrix or the the nested array, which then you can do your indices or your you know min-max forks on.
00:41:06.719 --> 00:41:17.519
But if you have classify where they're all jumbled together, can you actually do anything with that without you know having to split them up into the nested array that we got, anyways?
00:41:17.760 --> 00:41:20.639
Um so so I have a question for you, Connor.
00:41:20.800 --> 00:41:23.920
I can start doing the timings now, but the data is a bit interesting.
00:41:24.079 --> 00:41:27.599
If I just do random letters from the alphabet, we're going to have very few duplicates.
00:41:27.760 --> 00:41:29.760
That's also a question of how big should we make at least?
00:41:30.079 --> 00:41:32.960
Make it a thousand, uh make it just a thousand character string.
00:41:33.039 --> 00:41:33.840
That's all I want.
00:41:34.159 --> 00:41:36.000
One one thousand character string?
00:41:36.159 --> 00:41:37.360
Just one one thousand string.
00:41:38.239 --> 00:41:38.719
Yeah, yeah, yeah.
00:41:39.360 --> 00:41:39.519
Okay.
00:41:39.760 --> 00:41:42.639
And then we want to do uh F G H and I.
00:41:43.360 --> 00:41:44.159
Can we see the string?
00:41:44.239 --> 00:41:44.960
Let's see the string.
00:41:45.039 --> 00:41:45.920
Show us the string.
00:41:46.079 --> 00:41:47.440
Show me the string.
00:41:48.159 --> 00:41:49.360
You want me to scroll?
00:41:49.920 --> 00:41:50.719
Yeah, it's pretty good.
00:41:50.880 --> 00:41:53.679
I mean, and you know, everyone, everyone always says, Oh, blah, blah, blah.
00:41:53.760 --> 00:41:55.360
You gotta show all these.
00:41:55.519 --> 00:41:58.639
Have you got the the deaths out in a in a row?
00:41:58.960 --> 00:42:02.239
Um, I don't think I don't remember if it will show.
00:42:02.480 --> 00:42:03.599
Is that all varying?
00:42:04.000 --> 00:42:05.760
Never mind D there, we can erase that.
00:42:05.920 --> 00:42:06.320
I have no idea.
00:42:08.400 --> 00:42:11.599
And also the the shin might not be accurate.
00:42:12.000 --> 00:42:12.719
Good thing you didn't have any.
00:42:13.119 --> 00:42:13.280
It is.
00:42:13.360 --> 00:42:14.960
It's not the only time it fails.
00:42:15.119 --> 00:42:22.400
Yeah, the only time it fails is uh is if you've got things that have to be parenthesized, but it doesn't seem like it.
00:42:22.719 --> 00:42:25.440
But our intuition is h and this one.
00:42:26.159 --> 00:42:30.800
Wait, wait, before we do the intuition, so just just as a recap, we've got four functions here.
00:42:30.880 --> 00:42:32.480
They're called fgh and i.
00:42:32.559 --> 00:42:33.280
Not that that matters.
00:42:33.440 --> 00:42:37.440
F corresponds to the key solution that we showed right off the tap.
00:42:37.599 --> 00:42:40.000
Very beautiful, right off the tap, right off the top.
00:42:40.159 --> 00:42:41.679
That's the problem with live streaming, folks.
00:42:41.760 --> 00:42:43.599
Your speakos end up in the final cut.
00:42:43.760 --> 00:42:48.079
Then we've got G, which is the well, I guess we lost a selfie along the way.
00:42:48.159 --> 00:42:49.760
It was the selfie, selfie, selfie.
00:42:49.840 --> 00:42:52.559
You know, we're using the sigma combinator uh that we walked.
00:42:53.039 --> 00:42:55.199
We don't need it for this one because behind, right?
00:42:55.280 --> 00:42:57.280
So it really there should be one here, right?
00:42:57.440 --> 00:43:05.760
Because this it is essentially the self um index off with a with this behind text on.
00:43:06.000 --> 00:43:10.000
But the selfie is implied when it's monetic, so there's no need to do it.
00:43:10.079 --> 00:43:11.679
That's why I removed it here.
00:43:12.159 --> 00:43:12.960
Does that make any sense?
00:43:13.199 --> 00:43:18.480
Okay, because we can just if we don't have a left argument, we just use the right argument on the left, so that's it doesn't make a difference.
00:43:18.800 --> 00:43:37.840
But it was to show the relationship between formerly triple selfie, uh now double selfie, and then H and I are using the same uh min-max fork idiom, but one of them is using the uh unique outer product to get the indices corresponding to equal characters on each row.
00:43:37.920 --> 00:43:46.639
Uh, but then we learned the beautiful unique equals enclose fork, and the majority of those solutions are are the same.
00:43:46.880 --> 00:43:56.079
The interesting thing is after we uh profile this will be to is it gonna make a difference if we go in and uh replace some of the uh min's with firsts?
00:43:56.159 --> 00:43:59.039
But first, let's just uh compare is it running?
00:43:59.280 --> 00:43:59.840
Oh, look at that.
00:44:00.320 --> 00:44:02.000
Folks, we saw the intuition.
00:44:02.400 --> 00:44:16.320
Another thing I I changed a little bit uh uh analyzing the thing before, but uh I I ungulfed a little bit uh because of the it's more efficient to do the max first and then subtract one, then subtract one from a whole bunch of numbers and then do the max.
00:44:16.719 --> 00:44:19.039
So I changed that a little bit as you were talking.
00:44:19.280 --> 00:44:19.760
That's fine.
00:44:19.920 --> 00:44:22.079
But it doesn't make a huge difference.
00:44:22.639 --> 00:44:26.000
Well, so I mean the the listener, I mean we could we this doesn't looks wrong.
00:44:26.239 --> 00:44:30.000
We can still do the intuition, even though now we've run the expression.
00:44:30.320 --> 00:44:31.840
Um what were you gonna say, Rich?
00:44:32.320 --> 00:44:32.800
Just blind.
00:44:33.039 --> 00:44:35.280
I'm just I'm just covering up the in my own view.
00:44:35.360 --> 00:44:36.960
I'm just covering up for the audio listener.
00:44:37.039 --> 00:44:39.440
He's got a hand over the bottom half of his monitor.
00:44:39.760 --> 00:44:42.159
Oh, where the where results are.
00:44:42.320 --> 00:44:51.119
But it doesn't matter because it it sort of matches what I thought, except for Adam had already, if you were listening earlier, given the game away about F and G.
00:44:51.360 --> 00:44:55.920
The obvious big difference is between That's a lie, actually.
00:44:56.079 --> 00:44:57.840
I mean, it's slightly surprising.
00:44:58.000 --> 00:45:08.480
So H and I expect it to be a lot worse because they're both doing uh essentially out-of-products out-of-product comparisons between the entire individuals.
00:45:08.800 --> 00:45:11.760
Remember, it's not it's not uh n squared.
00:45:11.840 --> 00:45:13.199
We the unique is very small.
00:45:13.280 --> 00:45:16.800
Yes, there are a thousand elements, but we're only comparing them to 26 of them, right?
00:45:17.039 --> 00:45:18.480
So it doesn't matter as much.
00:45:18.559 --> 00:45:23.760
And the same thing goes for the difference between nested and flat in this case, very little, because there are only 26 elements.
00:45:25.599 --> 00:45:32.960
So it would be it would be much more interesting to have many many more different elements that it could be.
00:45:33.280 --> 00:45:34.159
I mean, we can do that.
00:45:34.639 --> 00:45:35.519
We can just do it with numbers.
00:45:36.000 --> 00:45:38.960
I think you want to add digits and uh uppercase random other.
00:45:39.599 --> 00:45:40.480
Just use numbers.
00:45:40.639 --> 00:45:42.239
Oh, yeah, just use numbers, yeah.
00:45:42.480 --> 00:45:43.679
Uh what am I doing here?
00:45:43.760 --> 00:45:55.360
Yeah, and then well, actually, first before you do uh a bunch of numbers, just do 0 to 25 or 1 to 26 to see if we get the same because you never know strings versus integer arrays.
00:45:56.000 --> 00:45:57.519
Yeah, no, we do know.
00:45:57.760 --> 00:46:04.480
We do if then yeah, because then the characters and and small numbers are stored identically internally.
00:46:04.639 --> 00:46:05.519
So yes, we do know.
00:46:05.920 --> 00:46:08.000
Show me and I will believe you.
00:46:08.239 --> 00:46:12.719
I I've I I've as a former C compiler compiler.
00:46:13.039 --> 00:46:15.199
Okay, so here instead of indexing.
00:46:16.559 --> 00:46:20.559
I trust nothing uh performance result-wise until I see it.
00:46:20.639 --> 00:46:37.119
Uh, because there's so many times where I've been like, well, obviously it does this, and uh you know compiling is so we can do this and and for uh so we I'm not sure if we actually fully it's like one bit difference in the internal representation between the numbers and the thing.
00:46:37.440 --> 00:46:39.199
Whoa! Look at that.
00:46:39.440 --> 00:46:40.559
Who was correct?
00:46:40.800 --> 00:46:41.119
Me.
00:46:41.360 --> 00:46:41.920
One second.
00:46:42.000 --> 00:46:43.440
No, no, no, did I make a mistake here?
00:46:43.679 --> 00:46:43.920
Maybe.
00:46:44.079 --> 00:46:52.480
So wait, and also why Adam is potentially fixing this, in case it wasn't clear for the audio listener, because we did some intuition, but then I'm not sure if we fully recapped.
00:46:52.719 --> 00:47:04.159
For the character string of uppercase letters, the slowest by a factor of two compared to the next uh actually, I guess we should do it as compared to the fastest.
00:47:04.320 --> 00:47:07.519
It looks like it's about five times, six, seven times slower.
00:47:07.599 --> 00:47:09.440
So it's the slowest one was the key.
00:47:09.599 --> 00:47:24.800
Then the outer products, um, the outer product and the uh kind of idiom that is similar to that, the unique equals enclose, uh, are very close, but the outer product is slightly faster, and that's about half the speed of the key.
00:47:24.880 --> 00:47:29.360
And then the fastest by far was the double selfie using the dyadic iotas.
00:47:29.519 --> 00:47:33.119
And now Adam is trying to fix the integer to match.
00:47:34.079 --> 00:47:40.719
Is that function that that uh Rich was warning about uh the diffs that this removes too many parentheses?
00:47:40.880 --> 00:47:44.559
It effectively removes too many, despite my thinking it was good enough.
00:47:44.719 --> 00:47:49.119
And we can see here that if you compare these two, I'll run this one again for the so yeah.
00:47:49.199 --> 00:47:57.199
This one uh I guess the noise between the outer product and the unique closed these these two have to compose compare.
00:47:57.280 --> 00:47:59.440
This is the numeric one, this is the text one, right?
00:47:59.519 --> 00:48:00.880
They are virtually identical.
00:48:01.119 --> 00:48:01.519
Okay, yeah.
00:48:01.599 --> 00:48:18.639
So that's just to say that the noise between the the last two solutions, H and I, that were the outer product uh unique and then you the unique equal enclosed, those are effectively you can count as the same because there's between the solutions one time, one was faster, the other one time, the other was slightly faster, and one of them they look identical.
00:48:18.719 --> 00:48:28.239
Uh so the point being is key is by far the slowest by like a factor of six, and the h and i, the outer product, and the equivalent uh you know, fork unique.
00:48:28.559 --> 00:48:29.599
What do we call that in idiom?
00:48:29.679 --> 00:48:32.079
We I guess we just call it unique equal enclose.
00:48:32.400 --> 00:48:39.440
Those are about three times as slow, and then the fastest by far is the diadic iota, which why is key so valuable?
00:48:41.039 --> 00:48:46.079
Because key in this case, we're giving it a uh oh a custom operand.
00:48:46.400 --> 00:48:47.360
Oh, that's a good point.
00:48:47.519 --> 00:48:54.000
If you rewrote this so that instead of a custom operand to key, you just did enclose omega.
00:48:54.559 --> 00:49:06.559
So you basically just rephrase key to become what uh it seems uh in BQN is in uh group, sorry, yeah, just group, group indices slash group.
00:49:06.800 --> 00:49:11.840
So we want to do and it's been argued that this is a way to do it.
00:49:11.920 --> 00:49:26.320
So like a little under the covers here is the the sort of rationale behind some operators, uh at least in dialogue is what you can do is because you know you can inspect the operands at runtime to see what the functions are actually spelled like.
00:49:26.559 --> 00:49:33.599
And by doing that, you can take some of those operands that you expect users to use and optimize them as special cases, right?
00:49:33.679 --> 00:49:35.920
And that only really works with operators.
00:49:36.400 --> 00:50:15.119
Um but of course it means you have to spell things in a particular way, unless you have something that's something like just in time compilation or something that can track, you know, there's this there's this idea that floats around called thunks, which is uh keeping track of things that have not yet been computed or that you intend to compute, and then passing that information along to future functions, and then they can look and say, Oh, you said you were going to compute this, but actually, since I'm gonna compute this other thing and I know what you were gonna give me, we can actually do this other thing that's faster instead of it uh materializing intermediate values.
00:50:15.440 --> 00:50:24.079
Anyway, that's the rationale, but in practice, you know, it's hard to anticipate, it's hard to uh produce all of those special cases.
00:50:24.159 --> 00:50:31.599
But one of the special cases for key, for example, in stencil is like this too, is just group the stuff and give it back to me as a nested array.
00:50:31.840 --> 00:50:42.400
And that is so fast with the special case that sometimes it's a lot faster to do the grouping and then apply your operand function with each instead of applying the operand function directly.
00:50:43.440 --> 00:50:45.440
So now I don't know this must have been a dialogue.
00:50:46.400 --> 00:50:50.320
Something yeah, something happened over here that uh that made it run slow.
00:50:50.639 --> 00:50:51.280
Here it is again.
00:50:51.360 --> 00:50:55.599
We can recognize this pattern from before, but now the key one is much faster.
00:50:55.679 --> 00:50:57.360
It's faster than the outer product ones.
00:50:57.679 --> 00:50:59.519
Right, which is what I would have expected.
00:50:59.760 --> 00:51:02.079
Yeah, so the only thing I did was you made here.
00:51:02.400 --> 00:51:07.360
So if you compare F, uh that we have uh next to each other.
00:51:07.679 --> 00:51:09.840
Yeah, I'm going to take the carry them down there.
00:51:10.079 --> 00:51:10.320
Cool.
00:51:10.800 --> 00:51:12.639
F there and F2 there.
00:51:12.880 --> 00:51:17.440
So firstly I switched to implicit, uh to explicit because too many.
00:51:18.960 --> 00:51:40.079
But uh basically what I did here was instead of feeding this giant custom operand to key, I'm just using this operand, which would be slow because it's the it forces nested arrays, but in fact, it is a a spelling that key recognizes, and instead of going through all these motions, it knows exactly what to do.
00:51:40.400 --> 00:51:43.360
Exactly, it's internally optimized, and so we go for go from there.
00:51:43.599 --> 00:51:50.880
Another thing that's interesting to look at is the instead of max, we want to do first and last, so we can try that as well.
00:51:51.280 --> 00:51:56.800
Yeah, if you do you could do right tack, you just switch something for the taxation from right and left and left.
00:51:57.039 --> 00:51:57.599
What do we call it?
00:51:59.039 --> 00:52:01.119
G G H H I I or whatever.
00:52:01.360 --> 00:52:04.079
I guess uh it doesn't matter so much.
00:52:04.239 --> 00:52:08.159
We can just call them uh I just have to find them uh here.
00:52:08.400 --> 00:52:11.440
This is the F1, right?
00:52:11.760 --> 00:52:14.320
So this is F A.
00:52:15.039 --> 00:52:19.679
We wanna replace uh the last and the first.
00:52:19.920 --> 00:52:20.800
Okay, right like this.
00:52:20.880 --> 00:52:22.800
It doesn't matter if it's how we start.
00:52:24.000 --> 00:52:29.119
And we want to do G doesn't matter, it's the same thing, it's obviously going to be fast still.
00:52:29.519 --> 00:52:36.559
And I here we wanna do the last one and the last one and the first one and the first one.
00:52:37.280 --> 00:52:40.639
F G H and I like that.
00:52:40.800 --> 00:52:41.519
And then we want to do that.
00:52:41.679 --> 00:52:42.960
Do you expect these to be faster?
00:52:43.199 --> 00:52:44.559
Yeah, a little bit at least.
00:52:44.719 --> 00:52:50.559
I'm not sure if it matters so much in the grand scheme of things, but uh but we can try it.
00:52:50.880 --> 00:52:56.079
See, this is where this is where, you know, I have uh what do you call it?
00:52:56.239 --> 00:53:01.280
I guess I don't have a name for it, but like there's these optimizations that you can make.
00:53:01.440 --> 00:53:19.840
Well, I mean I guess I guess this stuff is built into interpreters like dialogue APL and BQN, but like the you know, I I've always said if you keep track of the sortedness of stuff, you know, like uh you can make optimizations, like if you ever call min or max on a sorted sequence, it'll just dispatch to like the first or last.
00:53:20.000 --> 00:53:22.079
But then people say, Oh, like when would you ever do that?
00:53:22.239 --> 00:53:36.800
This is an example of where you know having those kinds of because I know that like I'm I'm not sure if dialogue tracks it, but I know Marshall said that in BQN he has a bunch of these like metadata flags that track the sortedness and whether it's Boolean, etc.
00:53:36.960 --> 00:53:38.639
And then they dispatch to different algorithms.
00:53:38.800 --> 00:53:39.760
This would be a perfect example.
00:53:39.840 --> 00:53:49.599
Like if we saw no perf difference, you might be able to assume that uh because the uh indices of the result of these operations are always going to be sorted, if you're able to track that.
00:53:49.920 --> 00:53:53.519
It would um and as we're I mean, uh Madeline's been posting in the chat.
00:53:53.679 --> 00:53:54.320
Oh, here we go.
00:53:54.400 --> 00:53:54.639
Never mind.
00:53:54.719 --> 00:53:56.400
We'll talk about the tiny APL.
00:53:56.480 --> 00:53:58.559
Uh yeah, we'll come I'm gonna look at this.
00:53:59.119 --> 00:54:00.239
Should I have sorted these?
00:54:00.320 --> 00:54:05.199
Uh yeah, just can you do the defs under underneath this and then we can show it all on one screen?
00:54:05.519 --> 00:54:15.920
It's sort of I can, but it remember the def doesn't show it really correctly, but it gives an idea what's what is supposed to happen because the it's missing parentheses around a bunch of them, but it doesn't matter so much.
00:54:16.239 --> 00:54:17.599
What's happened that's interesting?
00:54:17.760 --> 00:54:18.480
Oh yeah, okay.
00:54:18.639 --> 00:54:24.239
We're trying to do the right we really want to compare F with FA, so that's nine percent faster there.
00:54:24.480 --> 00:54:29.440
Wanna comp F2 uh it didn't mat F2 with F.
00:54:29.599 --> 00:54:33.280
Oh, yeah, but mean optimization is no no, I messed it up.
00:54:33.360 --> 00:54:34.880
I'll I'll redefine that.
00:54:34.960 --> 00:54:35.599
I messed it up.
00:54:35.760 --> 00:54:39.039
That's F2, and we want to do an F2A is this one.
00:54:39.280 --> 00:54:46.079
I really should just compare two that are the same with rights and left instead of max and min's instead of trying to put them all on one.
00:54:46.559 --> 00:54:52.320
F2A, but what I was thinking as we should do is just sort these instead of makes it easier to do it.
00:54:52.480 --> 00:54:53.599
So how did we do it?
00:54:53.760 --> 00:54:55.039
A top behind.
00:54:55.519 --> 00:55:10.559
For the audio listener, the last of last index of double selfie solution is still the fastest, but looks there looks to be small improvements to uh replacing the min reduction with a first.
00:55:11.039 --> 00:55:19.360
And I guess technically I was gonna say, have you did you replace replace the max reduction with a right write reduce, which is optimal.
00:55:19.840 --> 00:55:20.400
We can't do that.
00:55:20.480 --> 00:55:23.280
We can't do that here because you don't know which one is going to be the largest one.
00:55:23.360 --> 00:55:24.880
There we actually need the max.
00:55:25.440 --> 00:55:31.519
It's only the only the ones to find the indices, the first and last index, those are the ones that are that we can replace.
00:55:31.760 --> 00:55:33.199
Why do I have two F2s?
00:55:33.440 --> 00:55:34.000
Doesn't matter.
00:55:34.159 --> 00:55:39.119
But this shows us something about uh it shows something about the accuracy of the results.
00:55:41.440 --> 00:55:42.719
Because you wrote F2 twice.
00:55:42.960 --> 00:55:44.559
Yeah, I wrote it twice for mistake.
00:55:44.639 --> 00:55:48.480
It doesn't matter, but that knows that we can we can't we actually everything is like plus minus five percent anyway.
00:55:49.039 --> 00:55:54.880
So f2a, we can see that it it didn't really make a difference from F2 to F2A.
00:55:55.519 --> 00:55:59.760
Um F A is significantly f faster than F.
00:56:00.320 --> 00:56:04.159
Uh G, it doesn't matter because it doesn't use that technique.
00:56:04.320 --> 00:56:05.679
You can see A, you can see these.
00:56:05.760 --> 00:56:08.000
The H A is slightly faster than H.
00:56:08.480 --> 00:56:11.119
IA is slightly faster than than I.
00:56:11.360 --> 00:56:12.559
So yeah, it does make a difference.
00:56:12.880 --> 00:56:15.920
F A versus F where it's the biggest difference.
00:56:16.079 --> 00:56:21.039
That's probably where it's that's probably no yeah.
00:56:21.199 --> 00:56:24.880
It's no, it's the same amount, it's the same sort of percentage-wise difference, isn't it?
00:56:25.039 --> 00:56:26.480
Out of the whole total work.
00:56:26.880 --> 00:56:36.639
But they're direct uh directly comparable because they're the literally the same except ones using rights and left, ones using max and mints.
00:56:36.960 --> 00:56:55.280
And so there's another thing it's interesting, yeah, why because the number of times it's running should be this the number of times it's running should be it's just the number of unique elements for both the key.
00:56:56.400 --> 00:56:58.559
The way key is slowing everything down, yeah.
00:56:58.639 --> 00:56:59.360
I don't know.
00:56:59.599 --> 00:57:02.079
Yeah, I'm not sure why there's it's the same relative difference.
00:57:02.239 --> 00:57:05.599
Everything maybe key is just slows everything down inside itself.
00:57:05.840 --> 00:57:10.480
So easy so the relative difference between max and mean is just gets exaggerated in there.
00:57:10.559 --> 00:57:10.800
I don't know.
00:57:11.199 --> 00:57:13.440
Maybe every time I don't know.
00:57:14.079 --> 00:57:14.880
Oh, here's another thing.
00:57:14.960 --> 00:57:16.000
No, and here's another thing.
00:57:16.239 --> 00:57:20.480
Key might reparse its operand every time around the loop.
00:57:20.960 --> 00:57:26.800
But right tech reduction and left tech reduction are uh are tokenized as such.
00:57:26.960 --> 00:57:28.800
They're two cliff tokens actually.
00:57:29.039 --> 00:57:29.519
Oh right.
00:57:29.760 --> 00:57:33.119
So it might it doesn't need to reparse them, it's not actually a reduction at all.
00:57:33.599 --> 00:57:35.360
It doesn't go through reduction code at all.
00:57:35.440 --> 00:57:43.840
It immediately goes to the last last major cell function and the and the first major cell function, which are primitives in the interpreter, but not in the language.
00:57:45.280 --> 00:57:47.039
So yeah, okay.
00:57:47.440 --> 00:57:52.800
But as you can also see, it doesn't matter if we're using numbers or characters.
00:57:53.280 --> 00:57:57.599
If we if you compare those those two here, it's exactly the same time.
00:57:58.000 --> 00:58:02.159
Do we wanna you at one point we were gonna change it to have way more?
00:58:02.880 --> 00:58:03.920
Way more possibilities, yeah.
00:58:04.079 --> 00:58:05.119
So now we can do that, right?
00:58:05.199 --> 00:58:07.280
If we go up to well, we could just do it here.
00:58:07.360 --> 00:58:14.480
So if you do uh big n is a thousand, reshape one thousand instead.
00:58:14.639 --> 00:58:14.880
Right?
00:58:15.119 --> 00:58:18.400
So now there's there are much smaller chance of there being duplicates.
00:58:18.480 --> 00:58:20.000
There will be some big duplicates, right?
00:58:20.159 --> 00:58:22.800
So if you do G is the fastest one, right?
00:58:23.599 --> 00:58:26.639
So it's a very there are duplicates and they're far away from each other.
00:58:26.960 --> 00:58:28.719
Birthday problems abound here.
00:58:29.039 --> 00:58:31.599
Uh wanna run the unique on this as well.
00:58:31.920 --> 00:58:36.559
No, it doesn't matter because we need what do you do we want to run all of it on this big one as well?
00:58:36.800 --> 00:58:37.440
I guess so.
00:58:37.840 --> 00:58:50.320
Uh I guess I was thinking more just comparing like key and outer product, and so like just G I H or whatever we can pass it afterwards.
00:58:50.880 --> 00:58:54.880
Uh Madeline's index of solution by far the slowest.
00:58:55.360 --> 00:58:55.920
We'll show this.
00:58:56.000 --> 00:59:01.039
I mean, you guys aren't gonna see this, uh, but I've I've been compiling Madeline's solutions.
00:59:01.119 --> 00:59:04.480
I mean, if you look at the YouTube stream, it'll show up in a couple seconds for you.
00:59:04.639 --> 00:59:05.519
Uh or now.
00:59:05.920 --> 00:59:07.679
But Madeline has a couple different solutions.
00:59:07.760 --> 00:59:08.639
We'll look at this in a second.
00:59:08.719 --> 00:59:12.800
She's mentioned that her index of is the slowest, but that's just an implementation thing.
00:59:12.960 --> 00:59:15.039
But anyways, the solutions are back, folks.
00:59:15.199 --> 00:59:18.159
And now there's a big difference between some of them.
00:59:18.320 --> 00:59:22.639
No, because they're in different order as well, so it can't really start to compare.
00:59:22.880 --> 00:59:24.639
Uh so now there are many more.
00:59:24.800 --> 00:59:26.400
We can count the unique, right?
00:59:26.639 --> 00:59:28.559
Telly unique N.
00:59:28.960 --> 00:59:31.039
So there's six four unique values.
00:59:31.360 --> 00:59:34.719
That means there are very few, very few duplicates, right?
00:59:34.960 --> 00:59:42.320
And so just yeah, once again, because we've been uh you know, we're watching this on screen, so we don't have as much confusion as as I'm sure the audio listener does.
00:59:42.639 --> 00:59:47.519
Definitely have to go watch this on YouTube because honestly, this is uh this is a valuable educational material, folks.
00:59:47.599 --> 00:59:51.840
I'm learning a ton, and it's probably way easier to follow along if you're watching the video.
00:59:52.000 --> 01:00:08.639
However, if you really do like the podcast format, what we're doing now is we switched from our 26 uh possible characters in a lowercase or uppercase string to now uh an integer sequence of up to um anywhere to a maximum of a thousand possible values.
01:00:08.800 --> 01:00:19.280
And so in this test sequence, we have a thousand characters, and we just did a tally of the unique, and so there are six hundred and thirty-four, much higher than the possible 26 unique characters.
01:00:19.440 --> 01:00:26.559
And now we are going to see the impact on the profiling of the same solutions that we just looked at for the character string.
01:00:26.960 --> 01:00:30.159
See, my guess is what is I was gonna say he's looking for the maximum.
01:00:30.239 --> 01:00:34.559
I was gonna say it's either a thousand or he's looking at what's the most occurring thing.
01:00:35.039 --> 01:00:38.079
So the one that has the most duplicates has five duplicates, right?
01:00:38.400 --> 01:00:39.119
Interesting.
01:00:39.440 --> 01:00:44.880
So so this is a whole different it's a different set that we had before, and they're they're two-byte integers.
01:00:45.039 --> 01:00:50.800
Not that it matters a whole lot, but yeah, you can go looking for 64-bit floats if you want.
01:00:52.480 --> 01:01:01.280
So the trend is the same, it's just more exaggerated, where we we have a solution that was six to seven times faster, the index of compared to the slowest one.
01:01:02.320 --> 01:01:06.320
F A and F are the ones that are really slow, the key solutions there.
01:01:06.480 --> 01:01:16.639
Uh the F2, where we broke out uh the post-processing of the of the result from key, uh, is it takes half the time basically as before?
01:01:16.800 --> 01:01:19.599
It helps a little bit to do first and last, as before.
01:01:19.920 --> 01:01:22.400
Here, the this is plus minus five percent.
01:01:22.480 --> 01:01:28.079
So so by now everything is drowning out, and we yes, this is five percent faster with the first last.
01:01:28.320 --> 01:01:33.440
The fact that this one is slower than its first last one, I I wouldn't take that at face value.
01:01:33.519 --> 01:01:38.719
I would re-measure that if it was uh because I don't believe it.
01:01:38.960 --> 01:01:40.800
I mean C MPX, we just try it.
01:01:40.960 --> 01:01:46.639
C MPX, uh H big N and uh H A big N.
01:01:47.039 --> 01:01:52.800
I think it's just noise and uh and drowning because of the other things that are going on.
01:01:53.119 --> 01:01:53.679
There you go.
01:01:53.760 --> 01:01:55.519
Yeah, that's expected.
01:01:56.000 --> 01:01:57.679
So yeah, first last is better.
01:01:57.840 --> 01:02:00.079
This, I mean, I also get something out of this.
01:02:00.239 --> 01:02:06.239
This we this is helps me in in bolstering my view that we should add the last primitive.
01:02:06.480 --> 01:02:09.280
I think that would be like even conceptually nice things to have.
01:02:09.360 --> 01:02:11.760
So we could do like last minus first.
01:02:11.920 --> 01:02:12.480
That's one thing.
01:02:12.719 --> 01:02:18.559
Oh, because uh because people don't necessarily reach for the right tack reduce idiom.
01:02:18.639 --> 01:02:22.960
It's more of yeah, I think that's it's more obscure, right?
01:02:23.039 --> 01:02:24.000
And it's not the same either.
01:02:24.159 --> 01:02:27.199
Right tech reduces is last major cell.
01:02:27.280 --> 01:02:29.920
This would be last element in rebel order.
01:02:30.000 --> 01:02:30.719
It's not the same.
01:02:30.880 --> 01:02:38.079
It's last like it's not even last major last column or well, it's it's last really should be like this.
01:02:38.159 --> 01:02:39.360
This is last major cell.
01:02:39.599 --> 01:02:41.840
Last yeah, oh yeah, that's true.
01:02:41.920 --> 01:02:43.920
Sorry, yeah, it is last major cell there.
01:02:44.079 --> 01:02:44.400
Right?
01:02:44.559 --> 01:02:46.239
So how you want to write it, yeah.
01:02:46.559 --> 01:02:48.239
And this is first major cell.
01:02:48.559 --> 01:02:53.360
All right, and then we've got first column if you're right tag slash bar, left tack slash bar.
01:02:54.000 --> 01:02:56.559
And yes, sorry, I should speak this up so the listeners.
01:02:56.800 --> 01:03:06.000
And and yeah, and and left tech reduce, right tech normal, like last axis reduces, those are left and right columns in a matrix and not very meaningful in the higher dimensional array.
01:03:06.239 --> 01:03:10.239
And then we've got a first function that this as a disclosure one, right?
01:03:10.320 --> 01:03:13.599
It picks out the first element or coerces one out.
01:03:13.760 --> 01:03:20.400
That's another difference that you you can't do last element with a right tech reduction over an empty list.
01:03:20.719 --> 01:03:26.960
But you can ask, or you can't do the first one either, but you can get the first element which coerces out a prototype.
01:03:27.360 --> 01:03:28.559
So, how do you get the last one?
01:03:28.639 --> 01:03:38.480
So there actually is an a built-in idiom thing where if you it this tokenizes, but there's not always the combination and ends up nicely, you might need like in the top.
01:03:38.639 --> 01:03:45.519
So there's a a first of the reverse, which is also seem to be slow, but isn't if you're lucky.
01:03:45.920 --> 01:03:53.360
I think it would be nice to have a reverse, uh a last glyph, is something quite often, especially in this case, it was actually first and last.
01:03:53.519 --> 01:04:02.480
But I find that it's very often I want to operate on something that has exactly two elements, and I want to be able to address the left element and the right element, and that's also first and last.
01:04:02.800 --> 01:04:04.480
Um, so that's something I want.
01:04:04.559 --> 01:04:06.559
So that's one one thing that this has done for me.
01:04:06.719 --> 01:04:24.320
Another thing has done for me is this exact thing of key with the enclosed right argument, that means key that just works under on the indices and returns a list of indices, list of lists of indices, um, is an extension to key that that's key with vocabulary essentially.
01:04:25.920 --> 01:04:27.840
This is just a group by function.
01:04:28.159 --> 01:04:32.880
Sure, but key with vocabulary does accept that the my proposal for key with vocabulary.
01:04:33.280 --> 01:04:36.079
Oh, would do that as a monastery as well, right?
01:04:36.320 --> 01:04:36.719
Yeah.
01:04:37.119 --> 01:04:42.639
If no, you have to provide the vocabulary as yeah, but we in this case with the alphabet, we know what the vocabulary is.
01:04:43.039 --> 01:04:43.280
Sorry.
01:04:43.519 --> 01:04:43.760
Yeah.
01:04:44.000 --> 01:04:47.679
So if it al if sorry, so if we were to write how would you spell it?
01:04:47.760 --> 01:05:05.039
So right now it's doing open curly brace enclose omega right curly brace key, and that is the group by function returns a nested list, nested vector of your uh uh so with the vocabulary, it wouldn't yeah.
01:05:05.199 --> 01:05:09.039
Um what's called uh let's see if I can find those.
01:05:09.599 --> 01:05:10.800
Adam has a proposal.
01:05:10.960 --> 01:05:38.320
Well the key in dialogue at least, the one of the bugbears is that if you want to uh sort your results or if you want to have sort of um fill you want to have results that include uh zeros, for example, where an element an element type that you know about doesn't occur, yeah.
01:05:38.559 --> 01:05:54.320
Then you have to prov you have to prepend basically your onto your argument and sometimes onto your set of keys, a vocabulary, a set of you have to basically prepend with the unique elements that you're interested in in the order that you're interested in.
01:05:54.639 --> 01:05:59.519
Yeah, so if we do this, right, if you let's say we want to find letter frequencies, so here we can.
01:06:02.320 --> 01:06:08.239
So this this is not a useful result because we don't know what what they are, right?
01:06:08.480 --> 01:06:18.639
And even if we even if we do put in the left argument here, so we do like this, this doesn't give us the zero for all the letters that are missing, right?
01:06:18.880 --> 01:06:20.000
How many X's are there?
01:06:20.159 --> 01:06:20.639
We don't know.
01:06:20.880 --> 01:06:21.519
It doesn't say.
01:06:21.679 --> 01:06:23.119
We have to fill that in later.
01:06:23.360 --> 01:06:25.280
So that's uh that's a bit annoying.
01:06:25.440 --> 01:06:30.880
So the key with vocabulary, which of course it can do the same thing, but we can basically tell it.
01:06:31.039 --> 01:06:39.519
So if you go back to just this here, we tell it instead that the vocabulary is the alphabet.
01:06:39.760 --> 01:06:42.960
And now it gives us even the letters that are missing.
01:06:43.199 --> 01:06:46.000
And then we can go and and check for each one.
01:06:46.320 --> 01:06:56.239
So this is again this pattern of wanting actually wanting this and actually wanting for all of them, in our case it wouldn't it wouldn't matter because first and last it wouldn't have made a difference anyway.
01:06:56.480 --> 01:07:02.719
Oh we explicitly only care about the argument for the for the per weekly challenge.
01:07:02.960 --> 01:07:05.039
Sure, but but here's another problem then.
01:07:05.199 --> 01:07:10.000
So let's let's just say that we did have key with the vocabulary, and now we want to do the first and last.
01:07:10.639 --> 01:07:24.639
So we get we get these lists here, and one of the lists is uh the empty vector, and now we want to do the uh well, the last minus the first, and we get an error, like we said before, because they're not the same.
01:07:24.960 --> 01:07:34.800
Really, what we what we want to do is we want to get the first, which we can get, which is zero, and the last, which is zero, and subtract them from each other, which is zero, right?
01:07:34.960 --> 01:07:38.000
And then it's all good, but we're missing the last primitive.
01:07:39.039 --> 01:07:42.400
So um let's get that.
01:07:43.679 --> 01:07:46.960
Also, too, I I totally forgot that uh what was it?
01:07:47.199 --> 01:07:48.239
Let's go get the username.
01:07:48.320 --> 01:07:50.880
Was it uh D Zen Neroli?
01:07:51.199 --> 01:07:57.360
We said that we would mention the uh week if if uh they found the number, and they did.
01:07:57.519 --> 01:07:59.760
And then we were steeped in the solution.
01:07:59.840 --> 01:08:00.719
It would did we say it?
01:08:00.800 --> 01:08:01.760
Was it 372?
01:08:01.840 --> 01:08:02.719
Or did you say it, Rich?
01:08:03.199 --> 01:08:05.760
It is 372, whether or not it was said.
01:08:06.000 --> 01:08:06.480
Oh, yeah, yeah.
01:08:06.719 --> 01:08:07.440
So we might have failed.
01:08:07.519 --> 01:08:08.000
What are we at?
01:08:08.079 --> 01:08:10.239
We're at the like you know uh 80-minute mark.
01:08:10.400 --> 01:08:12.559
And so we might have failed to mention that this is.
01:08:12.639 --> 01:08:14.159
I mean, does it actually matter?
01:08:14.320 --> 01:08:21.439
Not really, but uh for folks in the future um that are 80 minutes into this, being like, wow, where's the problem statement?
01:08:21.600 --> 01:08:25.840
And potentially too, this is kind of a classic uh interview e.
01:08:25.920 --> 01:08:32.720
I bet if I search this uh on Google, it also corresponds to like a leak code problem.
01:08:32.880 --> 01:08:34.960
Um anyways, back to you, Adam.
01:08:35.119 --> 01:08:35.359
Sorry.
01:08:35.520 --> 01:08:36.079
No, that's fine.
01:08:36.159 --> 01:08:45.840
I'm just I'm just showing how the key that always does uses that function but with vocabulary, it would still work because we'd get uh we'd get these distances being zero here.
01:08:46.159 --> 01:08:52.399
Yeah, but then you get a bunch of negative ones for things you don't care about or it doesn't matter because we want the maximum, right?
01:08:52.640 --> 01:08:53.600
Oh, you're right, yeah.
01:08:53.840 --> 01:08:57.600
And then and then subtract one, so sure it actually doesn't matter.
01:08:57.840 --> 01:08:58.319
Well.
01:08:58.640 --> 01:09:07.760
And it is indeed lead code problem 1624 with a much more specific name of largest substring between two equal characters.
01:09:08.159 --> 01:09:11.039
So I was thinking about this because what am I going to call this episode?
01:09:11.199 --> 01:09:16.560
Should I call this episode like key versus index of versus outer product?
01:09:16.800 --> 01:09:20.000
Because honestly, that is what's more I think important here.
01:09:20.079 --> 01:09:41.039
Is like we're discussing the trade-offs between primitives, how it affects your solution, uh, or do I call it like PwC, you know, 372 part two, which means absolutely nothing to like people of the interwebs, but like will mean like when I think about this uh episode in the past, like I will think about, oh yeah, that's the time we solved that pro-weekly challenge problem.
01:09:41.359 --> 01:09:44.479
Like, so uh you know, it's uh what should we actually call this?
01:09:44.560 --> 01:09:46.720
Because currently this episode does not have a title.
01:09:46.800 --> 01:09:52.960
Uh the you know, repeat listeners will know that uh we just called it 125 and we're gonna we're gonna add a title later.
01:09:53.039 --> 01:09:56.000
So yeah, it was a big problem for us at dialogue, by the way.
01:09:56.159 --> 01:10:04.800
And we our website people were unable to put this episode on our calendar of upcoming events because there's nothing to put in the title.
01:10:05.199 --> 01:10:07.600
See they can't just put array cast 125.
01:10:07.680 --> 01:10:09.439
That's not uh that's not enough information.
01:10:09.600 --> 01:10:10.640
Uh I guess not.
01:10:10.720 --> 01:10:12.079
That's a value or something.
01:10:12.399 --> 01:10:14.399
Choose in advance when you're not interested.
01:10:14.560 --> 01:10:18.079
Um so so yeah, I think I think this is pretty neat.
01:10:18.239 --> 01:10:22.479
Um I I I would think that key with vocabulary can be made faster.
01:10:22.640 --> 01:10:37.520
My model isn't intended to be fast in any way, but I would think it could be faster because key, when it starts working, normal key, it doesn't know like uh like for with this function of in-close omega, it doesn't know how many unique elements there are.
01:10:37.680 --> 01:10:37.920
Right?
01:10:38.079 --> 01:10:55.680
It will have to traverse first and find out what are all the unique elements, or as it goes along, it will have to make more and more uh result collection pockets where it's going to keep adding in in indices, but it doesn't know how many they're going to be, so it doesn't know how much space to reserve for each one of them either.
01:10:55.920 --> 01:11:01.520
I would think that it would be advantageous for key to know in advance that I'm only looking for these 26 letters.
01:11:01.600 --> 01:11:05.760
That means if I find any elements that are not among these 26 letters, I'm not going to consider them.
01:11:06.159 --> 01:11:07.119
Just going to skip them.
01:11:07.279 --> 01:11:12.960
So it knows it can start building up slots of uh 26 slots.
01:11:14.000 --> 01:11:18.479
It doesn't know how many it's gonna find, so I don't think that's true, but now it has some bound on them.
01:11:18.560 --> 01:11:25.920
It knows they're going to be a great many duplicates, so it could at least on average, or some kind of uh I don't know, geometric average thing.
01:11:26.000 --> 01:11:39.359
You could it could start off by reserving like at uh twice the or something like that, the the total number of elements divided by the number of elements we're looking for, something like because it knows it's going to fill at least quite a few of them.
01:11:39.439 --> 01:11:40.800
Then it can always compact it later.
01:11:40.880 --> 01:11:43.039
Something like I mean I don't know, I'm not a supercommer.
01:11:43.199 --> 01:11:54.560
I think I think some things could there's some tricks they could do sort of uh guess to best guess and compact things later rather than having to be completely in line to what's going to be later.
01:11:54.960 --> 01:11:55.840
Indeed.
01:11:56.239 --> 01:12:00.800
Um and you could um if this works in the model actually.
01:12:02.479 --> 01:12:06.560
Connor, as we surpassed minute 83 or so.
01:12:06.800 --> 01:12:09.439
You had the collection of uh Madeline's tiny.
01:12:09.760 --> 01:12:12.239
Yeah, should we show we should we show those uh the solutions?
01:12:12.640 --> 01:12:13.600
You want me to stop sharing?
01:12:13.760 --> 01:12:14.239
You can show those?
01:12:14.640 --> 01:12:19.840
Yeah, I'll uh I'll steal how do we do the entire screen Google NeWorks.
01:12:20.000 --> 01:12:26.000
It's a little behind the scenes for the YouTube people because they can see for like three seconds my uh monitor, my multiple monitors.
01:12:26.159 --> 01:12:27.840
Uh show my screen, anyways.
01:12:28.079 --> 01:12:28.640
There we go.
01:12:28.800 --> 01:12:33.920
And so now I'm gonna be staring at my top monitor, even though you know You want to click that button.
01:12:34.159 --> 01:12:34.640
What button?
01:12:34.800 --> 01:12:35.439
Oh yeah, yeah, yeah.
01:12:36.079 --> 01:12:38.640
So you're behind now, but uh if you it depends on whether you're watching the YouTube.
01:12:39.199 --> 01:12:40.640
So what page is this as well?
01:12:40.960 --> 01:12:42.159
Is this the array box?
01:12:42.560 --> 01:12:44.239
My uh my array box is array.
01:12:44.479 --> 01:12:46.079
Is this the array box that's up?
01:12:46.319 --> 01:12:47.840
Yeah, and it's beautiful, folks.
01:12:47.920 --> 01:12:59.600
I mean I tweeted the other day that you know the AI hack is I now have like vibe I've gotten the AI to program me GitHub actions that like monitor when there's ever updates to WiWAM, J.
01:13:00.000 --> 01:13:08.800
And then whenever it notices an update, it automatically kicks up another GitHub action that goes and like pulls down the source, compiles it, gets the WASM executable.
01:13:08.960 --> 01:13:13.760
So now every once in a while I just get a pull request on this repo that says, hey, we got you the new version.
01:13:13.840 --> 01:13:14.960
I just click merge.
01:13:15.119 --> 01:13:15.680
It's beautiful.
01:13:15.840 --> 01:13:16.640
Everyone else was upset.
01:13:16.720 --> 01:13:19.520
They're like, oh, you've exposed yourself to supply J attacks.
01:13:19.680 --> 01:13:23.279
Listen, folks, if I get a supply chain attack, we're doing great.
01:13:23.439 --> 01:13:28.479
That means that people care enough about this website that they want to like, you know, uproot uh what I'm doing here.
01:13:28.560 --> 01:13:29.600
So we've got all the different languages.
01:13:29.920 --> 01:13:32.479
But you're only you're only try uh pulling from trusted people, right?
01:13:32.640 --> 01:13:32.880
Exactly.
01:13:33.279 --> 01:13:34.960
All the array programs you know personally.
01:13:35.600 --> 01:13:36.640
Corrupt one of the array lines.
01:13:37.039 --> 01:13:40.239
People are just so anti-AI that like they're like, oh, you know, that doesn't work.
01:13:40.319 --> 01:13:45.520
And it's like, I used to do this manually and it was it was so just like laborious, and now it's so pleasant.
01:13:45.680 --> 01:13:49.359
I just like I wake up in the morning, I'm so excited to go to my computer, I'm like, ooh.
01:13:49.680 --> 01:13:50.800
You heard that first, folks.
01:13:50.880 --> 01:13:59.359
Here, if you can put in a supply chain attack that puts some funny message on arraybox.com, Connor will give you a prize.
01:13:59.680 --> 01:14:00.880
Hey, I did that first.
01:14:01.119 --> 01:14:02.399
Madeline, uh yeah, that's true.
01:14:02.479 --> 01:14:07.359
That was before you were one of my went live and then was like, here, kinda trust AI too much.
01:14:07.600 --> 01:14:08.640
You know the sentence scene.
01:14:08.800 --> 01:14:09.840
I gave it to Madeline recently.
01:14:10.880 --> 01:14:14.399
Yeah, Madeline saying in the chat, you shouldn't trust me, and it's like, all right, well, that's my own fault.
01:14:14.479 --> 01:14:20.399
If you want to take down a RayBox with a uh you know, malicious release of Tiny Apple, it serves me right.
01:14:20.640 --> 01:14:31.359
But I was giving a uh uh talk recently at NDC Toronto just like a week and a half ago, and I used Tiny Apple uh for all of the code and like live coded the entire talk.
01:14:31.520 --> 01:14:35.119
And the reason that I used Tiny Apple is one, it has all the primitives.
01:14:35.199 --> 01:14:39.119
You know, when you look at the keyboard, it's just like holy smokes, we got everything, folks.
01:14:39.279 --> 01:14:40.800
Uh, and that's fantastic.
01:14:40.960 --> 01:14:51.680
In fact, I was thinking as soon as I was solving this in my head at the beginning, I was immediately mapping like, uh, what languages have primitives that would be a little bit nicer?
01:14:51.840 --> 01:14:56.720
And I thought, oh yeah, J has decrement and increment, which is plus one, minus one.
01:14:56.880 --> 01:15:03.199
That'd be nice, except for the fact that they're actually two characters in J, so it doesn't save you anything compared to like a minus one or a plus one.
01:15:03.359 --> 01:15:10.560
And then I forgot until I saw Madeline's solutions that, oh, that's right, uh uh Tiny Apple pretty much has everything.
01:15:10.720 --> 01:15:16.319
And so if you uh look at what the double dash except in a single Unicode primitive, this is decrement.
01:15:16.560 --> 01:15:20.239
Uh so you can I don't actually know if this saves, probably does save one character.
01:15:20.399 --> 01:15:26.079
Um but anyways, I uh I was mentioning that the reason I used Tiny Apple was one because it has all the primitives.
01:15:26.159 --> 01:15:31.680
Like I would have typically used BQN, but BQN didn't have the partition functions, partition and partition and close.
01:15:31.760 --> 01:15:32.640
And so I needed those.
01:15:32.720 --> 01:15:34.800
And then when you think, why wouldn't you use dialogue APL?
01:15:34.880 --> 01:15:36.159
Because dialogue APL has those.
01:15:36.239 --> 01:15:46.479
However, if we quickly copy this and we go to uh dialogue APL, if you try to uh output multiple things, so if I do like what do we just do?
01:15:46.640 --> 01:15:49.840
I guess we can just type a thing and then we do four, five, six.
01:15:50.000 --> 01:15:55.439
Because of the safety mechanisms that I put in place, you can well, is it because of this?
01:15:55.600 --> 01:16:02.800
Usually, actually, this says that I can't uh do this, or or maybe this isn't because of, but anyways, I'm using the Safe3 dialogue thing.
01:16:03.039 --> 01:16:11.119
And I don't know if that's what prohibits this, but multiple uh uh outputs don't work, whereas Tiny Apple, I have no problem.
01:16:11.359 --> 01:16:14.399
Uh I need I I just it just struck me now.
01:16:14.560 --> 01:16:33.920
I was uh I was at the BAA meeting, uh the Bridge APL Association at this bi-weekly meeting, and I was showing some old code that I converted from uh some APL 360 code, and I converted it to this MyServer thing that you can say interactive thing, and how I'd mangled the code so you can do things that sort of like session.
01:16:34.000 --> 01:16:45.520
And it just struck me now that maybe the safe code could do something like where it goes in and replaces all the quad get tokens, basically, uh dual tokens, with something that collects output.
01:16:45.680 --> 01:16:53.680
So it might not be able to show output in real time, but every when you run it, it will collect all the output and show you all the output you sped out on the way.
01:16:53.840 --> 01:16:54.720
I think I can do it.
01:16:54.960 --> 01:16:55.840
Yeah, potentially.
01:16:56.000 --> 01:17:00.960
Um anyway, so look forward to uh NDC Toronto uh it was called Algorithms and Combinators.
01:17:01.039 --> 01:17:14.720
It was a beautiful talk, folks, and I had a live coded, or well, not live coded, I had a vibe-coded live poll that was running like a reverse cloud fair tunnel on my laptop, and it had this beautiful pie chart animations of showing what languages people were using.
01:17:14.960 --> 01:17:16.399
Only possible thanks to AI.
01:17:16.479 --> 01:17:19.840
Um, but let's stop talking about AI and start talking about these solutions.
01:17:19.920 --> 01:17:20.880
So this was Madeline.
01:17:20.960 --> 01:17:26.079
So Madeline, creator, if you're not familiar, of the Tinel Tiny Apple language that we're looking at right now.
01:17:26.239 --> 01:17:29.600
So this is the uh index of solution, LOF or last index of.
01:17:29.840 --> 01:17:32.720
This is the key solution, and this is the original solution.
01:17:32.960 --> 01:17:35.520
So, I mean, we can look the through these primitives.
01:17:35.600 --> 01:17:45.119
So this is the group, which I believe uh initially comes from Cap and BQN, or maybe BQN had it first, and Cap added it later.
01:17:45.439 --> 01:17:50.800
And I don't fully actually so like this is so let's remark on the nice things first.
01:17:50.960 --> 01:17:58.000
So um uh Tiny Apple has the uh first, um, although it's called uh last.
01:17:58.239 --> 01:17:59.520
Uh and this is the first.
01:17:59.680 --> 01:18:01.520
So we've got first and last primitives.
01:18:01.680 --> 01:18:06.720
It's using the um cap syntax for forks in this case.
01:18:06.880 --> 01:18:12.399
Uh, and then we have the you know, max reduce, we have the decrement function, which is quite nice.
01:18:12.560 --> 01:18:14.880
What happened to my oh yeah, there we go, decrement.
01:18:15.359 --> 01:18:24.720
And uh this I was a bit confused of at first, but I'm pretty sure backward is just another way for the flip or swap.
01:18:25.039 --> 01:18:26.159
No, no, no, no, no.
01:18:26.239 --> 01:18:28.239
This is this is exactly what I was doing before.
01:18:28.399 --> 01:18:33.119
Look, this is the one that looks at the that's the the the classifier thing, right?
01:18:33.199 --> 01:18:35.199
We look for the first position in itself.
01:18:37.520 --> 01:18:43.359
So there's a backwards, it's basically a modifier, it's not a normal operator, it's special.
01:18:43.439 --> 01:18:50.159
I think it's use a lookup table and it modifies iota to behave from the back end, right?
01:18:50.319 --> 01:18:52.560
So so this is a variant, if you want.
01:18:53.039 --> 01:18:54.560
Really, it's just a spelling scheme.
01:18:55.039 --> 01:18:56.720
Iota of from the end.
01:18:57.119 --> 01:18:57.520
Yeah.
01:18:57.840 --> 01:19:07.439
So it's basically it's basically uh a primitive that could be spelled with multiple primitives as uh under reverse, correct?
01:19:07.680 --> 01:19:07.920
No.
01:19:08.079 --> 01:19:09.039
Uh no, exactly.
01:19:09.439 --> 01:19:14.079
Then I would have done that because you have to subtract from the it's it's position of the last, right?
01:19:14.399 --> 01:19:15.039
Oh, right, right.
01:19:15.520 --> 01:19:16.479
It's it's a different primitive.
01:19:16.560 --> 01:19:17.600
It's look for the last element.
01:19:17.680 --> 01:19:18.479
It's not the same thing as well.
01:19:19.680 --> 01:19:20.159
That's incorrect.
01:19:20.239 --> 01:19:20.479
Yeah, yeah.
01:19:20.560 --> 01:19:23.439
I should have the two words the tally minus earlier.
01:19:23.680 --> 01:19:23.920
Yeah.
01:19:24.079 --> 01:19:33.680
And uh Madeline in the chat is saying Elias, the creator of uh cap, uh, and uh they added them at the same time for the group primitive.
01:19:33.920 --> 01:19:35.199
Um so very beautiful.
01:19:35.279 --> 01:19:38.640
I mean, we've got the banana brackets in order to get the train syntax.
01:19:38.800 --> 01:19:58.720
And so this is the only thing that so I mean this is the group primitive from BQN, but it's uh equal group uh iota tally, which I don't I don't fully um and you can see that I had it here because except this was a mistake putting this because I wanted to I don't have uh actually I can just go up.
01:19:58.800 --> 01:19:59.920
Yeah, yeah, keep it this way.
01:20:00.000 --> 01:20:08.319
And you can see that I had it here because I was trying to just evaluate this, and if you get rid of can you do it with I don't think you can do it without that.
01:20:08.479 --> 01:20:10.640
Actually, no, wait, wait, wait, I'm doing this incorrectly.
01:20:10.800 --> 01:20:12.880
Uh I want to do shift enter.
01:20:13.039 --> 01:20:24.159
So this uh, which is just the equal group iota tally of the string, gives us the indices of the you know, a, b, and c oh.
01:20:24.560 --> 01:20:26.960
Is there some kind of thing going on?
01:20:27.039 --> 01:20:31.279
It's using the elements as the key into the group.
01:20:31.520 --> 01:20:32.399
Is it something like that?
01:20:32.640 --> 01:20:36.239
Well, so like it's grouping the indices, that's why it's doing the iota tally.
01:20:36.479 --> 01:20:38.159
So it's giving you need to get the indices first.
01:20:38.560 --> 01:20:40.319
This is just this is just a key, right?
01:20:40.399 --> 01:20:43.760
This is just yeah, but it's a key spelled of like five glyphs.
01:20:44.159 --> 01:20:46.720
Yeah, but the iota tally is the are the indices.
01:20:46.960 --> 01:20:48.079
Yes, iota tally exactly.
01:20:48.159 --> 01:20:56.079
That's what I'm saying to Connor, is the data you want to group is the indices, not the I think if you get rid of that, does it just group the characters?
01:20:56.560 --> 01:20:59.279
Uh or is there a write tech or something?
01:20:59.520 --> 01:21:00.079
Yeah.
01:21:00.319 --> 01:21:00.720
Yeah.
01:21:01.279 --> 01:21:06.479
So instead of grouping the characters, you want to group the indices at which they occur, which is the one.
01:21:06.640 --> 01:21:07.520
What is the equal do?
01:21:07.760 --> 01:21:13.199
I was gonna say I'm guessing that this has to be a binary operation that's passed to group.
01:21:13.359 --> 01:21:13.600
No.
01:21:14.239 --> 01:21:19.439
Well, they know because you've got the wrong domain there, you can't less than characters, but you might be on to something.
01:21:19.760 --> 01:21:21.039
Well, what is equal?
01:21:21.359 --> 01:21:22.399
Monetic equal.
01:21:24.960 --> 01:21:26.640
Madeline in the comments explain.
01:21:29.840 --> 01:21:30.640
Although, why is it blue?
01:21:31.119 --> 01:21:31.840
Oh, it's classifying.
01:21:31.920 --> 01:21:32.560
Oh, okay, okay, okay.
01:21:33.439 --> 01:21:34.079
It's classified.
01:21:34.239 --> 01:21:34.640
That's fine.
01:21:34.720 --> 01:21:36.159
So it's my docs have failed.
01:21:36.319 --> 01:21:37.760
My docs have failed.
01:21:38.000 --> 01:21:38.399
Yeah.
01:21:38.640 --> 01:21:43.039
No, because it's um Madeline forgot to cla document it.
01:21:43.119 --> 01:21:43.520
Uh-huh.
01:21:44.079 --> 01:21:50.079
Well, we can't blame Madeline yet because my guess is that it is documented and my scraping script missed it.
01:21:50.159 --> 01:21:55.039
Uh, I would I would trace try I trust the AI vibe coded uh doc scraper.
01:21:55.439 --> 01:21:59.279
Although never mind, it was it was Madeline's fault.
01:21:59.359 --> 01:22:01.920
She says, Oh, I did forget to document it.
01:22:02.720 --> 01:22:11.359
So this is if we go to uh BQN quickly um and we delete this, this is the and I can never remember how to spell this.
01:22:11.520 --> 01:22:12.800
I gotta is it this one?
01:22:12.960 --> 01:22:13.520
Is it this one?
01:22:13.840 --> 01:22:14.399
Is it this one?
01:22:14.640 --> 01:22:14.960
There we go.
01:22:15.279 --> 01:22:18.079
That one with is your cla is your group.
01:22:18.319 --> 01:22:19.039
No classify.
01:22:19.279 --> 01:22:19.600
There we go.
01:22:19.680 --> 01:22:22.960
So this is the idiom in this is classify, I think, right?
01:22:23.039 --> 01:22:26.560
So if we do F1 classify, and yeah, this is group.
01:22:26.880 --> 01:22:33.039
Uh so and this is an idiom that I um am very familiar with in BQN because it comes up a ton.
01:22:33.279 --> 01:22:38.399
So in uh Tiny Apple, it looks uh like it.
01:22:38.640 --> 01:22:48.079
I guess it would look like this in the case where you were grouping the own stuff, but in this case you actually want the fork where Iota tally is uh the right tyne.
01:22:48.239 --> 01:22:54.880
Um so yeah, this is a fork that is yeah, doing classify group on the indices.
01:22:55.119 --> 01:22:59.760
Which is, I mean, the uh we haven't said this for the audio listener, but this is definitely the most verbose solution.
01:22:59.920 --> 01:23:05.840
Then the key shaves off four characters or five, and the index of shaves off one more.
01:23:06.079 --> 01:23:18.159
Um although Madeline did mention that the index of for her uh Tiny Apple is actually much slower, but that's not because I don't think it couldn't be faster, it's just the implementation currently.
01:23:18.399 --> 01:23:39.199
Are there any other things worth remarking on in so I mean it's it's very love, this is why I love Tiny Apple though, because it's got you know the it's got the last, it's got the first, it's got all the primitives, and so whenever like it always makes me so sad when you go to BQN and you need you or you want like the decode and the encode, or you want the partition primitives.
01:23:39.439 --> 01:23:47.680
Um and uh for playing around, Tiny Apple it's always very nice because and that's the thing is I I wasn't even aware of this backward.
01:23:47.920 --> 01:23:53.199
Um but you can like maximally play around with the different algorithmic solutions for this.
01:23:53.520 --> 01:23:55.600
And uh I guess I should delete this at the point.
01:23:55.840 --> 01:24:00.079
And it makes me want to find the docs for backwards.
01:24:00.319 --> 01:24:00.800
There it is.
01:24:00.960 --> 01:24:03.680
So I mean I can't show other things that can do that.
01:24:03.840 --> 01:24:06.720
Oh, it doesn't say if I look at the full full docs.
01:24:07.359 --> 01:24:16.880
Backward doesn't tell you what things can go backwards, but the things that can go backwards oh also don't tell you because it was for because Madeline forgot to document it.
01:24:16.960 --> 01:24:17.920
Yeah, okay, fair enough.
01:24:18.159 --> 01:24:21.920
I just realized that I an optimization that I well, whatever.
01:24:22.000 --> 01:24:25.359
I weigh it's a nicer spelling of things, I think.
01:24:25.680 --> 01:24:30.800
And I guess this is the problem with not having a full panel, because there was a J solution at one point that didn't use key.
01:24:31.760 --> 01:24:32.640
I have a J solution.
01:24:33.199 --> 01:24:34.319
I have it to present.
01:24:34.479 --> 01:24:35.119
You want me to present?
01:24:35.359 --> 01:24:36.079
Yeah, yeah, yeah, sure.
01:24:36.880 --> 01:24:37.520
Steal it away from me.
01:24:38.640 --> 01:24:43.199
Um it irritates me because this YouTube recording, it's I'm staring up at my ceiling basically.
01:24:43.920 --> 01:24:47.039
So it's it's nicer if uh someone else's uh screen share.
01:24:49.439 --> 01:24:55.520
I'm not a J programmer, so I don't know what I'm doing here, but uh this seemed to work, and I just realized something.
01:24:55.840 --> 01:24:56.319
Oh, look at that.
01:24:56.479 --> 01:24:57.279
We're in Juno, folks.
01:24:57.359 --> 01:25:01.119
Look at that dovetailing from episode 124 with uh Juno.
01:25:01.840 --> 01:25:09.600
Uh so so this so this is the index of this is index of selfie, and this is index of last, which is a primitive in J selfie.
01:25:09.760 --> 01:25:10.800
So this is super easy.
01:25:10.960 --> 01:25:12.479
So subtract those from each other.
01:25:12.560 --> 01:25:15.760
Maybe I should tokenize this for you because I can I can't read J like this.
01:25:15.920 --> 01:25:16.159
Sorry.
01:25:16.399 --> 01:25:19.359
I mean it has different colors and it's all nice here, but uh seriously I can't.
01:25:19.840 --> 01:25:29.199
Uh okay, so index of last selfie, uh minus index of first selfie, maximum nothing over here.
01:25:29.279 --> 01:25:32.399
This is the cap uh thing, and then subtract one.
01:25:32.479 --> 01:25:33.680
So this is this is a solution.
01:25:33.840 --> 01:25:37.520
And I just realized together, you can put the slash next to the max.
01:25:38.079 --> 01:25:38.479
What?
01:25:38.720 --> 01:25:39.119
Right?
01:25:39.279 --> 01:25:39.840
Is that right?
01:25:40.000 --> 01:25:40.399
Right.
01:25:40.640 --> 01:25:42.960
Uh is yeah, that's one thing.
01:25:43.199 --> 01:25:45.439
Yeah, I mean if you want, but this is the thing.
01:25:47.039 --> 01:25:47.359
Yeah.
01:25:49.680 --> 01:25:53.439
I just realized a couple of things, a couple of things that are nice here.
01:25:53.600 --> 01:26:01.760
One is I believe, and we can apply this to the APL, we can go back and do the APL afterwards, is we can break out the selfie over here, I believe.
01:26:02.079 --> 01:26:03.119
Uh like that.
01:26:03.359 --> 01:26:09.119
That still works because it's just a now it's just indexed off the left argument, which is so it's not as so that's nice.
01:26:09.359 --> 01:26:12.479
And this, I believe we can make this an inner product.
01:26:12.800 --> 01:26:19.600
But the inner product is not spelled any better in J, really, because you have to do like this, I think, to do inner product, but it gets rid of the can.
01:26:21.439 --> 01:26:24.479
Yeah, in J you do, but not in the okay, fair enough.
01:26:24.800 --> 01:26:26.960
Um and then so this is this is the whole solution.
01:26:27.039 --> 01:26:28.159
We can get rid of the spaces now.
01:26:28.239 --> 01:26:29.039
We can almost read it.
01:26:29.439 --> 01:26:35.600
Max dot minus can't remove this space, I believe, because then it's dot slash, which means something completely different.
01:26:35.840 --> 01:26:38.319
Uh but this is pretty nice, isn't it?
01:26:38.640 --> 01:26:44.479
Minus one plus the slightly shorter max dot minus index of the first.
01:26:44.800 --> 01:26:45.840
Can't you do a decrement?
01:26:46.000 --> 01:26:47.199
Or is that gonna be longer?
01:26:47.760 --> 01:26:52.159
Oh yeah, we can do a decrement, but it doesn't help because that would need a cap.
01:26:52.640 --> 01:26:53.039
Right.
01:26:53.199 --> 01:26:55.359
Because because you can't do a tops like this.
01:26:55.439 --> 01:26:57.680
So it doesn't really that's the worst part of J, folks.
01:26:58.159 --> 01:27:05.119
I say it because Henry's not here, but uh the the two train being the S combinator, frankly, big mistake.
01:27:07.920 --> 01:27:09.039
is key in J.
01:27:09.359 --> 01:27:10.479
Yeah, so we can use key.
01:27:10.560 --> 01:27:12.079
Yeah, but it's not not just slash dot.
01:27:12.239 --> 01:27:16.399
I think there's two keys because they realized that the dialogue key was so nice that they wanted that too.
01:27:16.560 --> 01:27:20.479
So there's so this is the key, and then there's like well that was Roger's fault, was it?
01:27:20.960 --> 01:27:25.680
Uh he brought uh J stuff into the key diet, yeah.
01:27:25.760 --> 01:27:26.319
This one.
01:27:26.560 --> 01:27:29.279
But anyway, so yeah, you can use it with the key.
01:27:29.359 --> 01:27:31.119
I'm not really sure how that works.
01:27:31.279 --> 01:27:35.520
We can try it if you want, but I'm not I mean scary stuff.
01:27:36.319 --> 01:27:38.159
Unknown territory here for AP.
01:27:39.039 --> 01:27:40.000
AKLE killers.
01:27:40.399 --> 01:27:43.840
I think we like like enclosed uh that did not work.
01:27:44.079 --> 01:27:47.039
Oh right, because we want I'm not doing I don't even know.
01:27:48.640 --> 01:27:49.039
That's right.
01:27:49.119 --> 01:27:49.279
Yeah.
01:27:49.760 --> 01:27:52.479
No, no, it's not because this doesn't give us the the indices.
01:27:52.800 --> 01:27:54.800
No, no, you have to provide the indices.
01:27:58.000 --> 01:27:59.279
So it's in an I dot.
01:28:00.399 --> 01:28:01.680
Like a hook or something.
01:28:02.000 --> 01:28:08.159
Uh we have to do like or uh compose i dot compose with the tally.
01:28:08.560 --> 01:28:08.800
Yeah.
01:28:09.119 --> 01:28:11.039
Just like this or something like that, right?
01:28:11.359 --> 01:28:12.800
Yeah, so these are the indices.
01:28:13.199 --> 01:28:15.760
And then we want to group by indices.
01:28:15.840 --> 01:28:20.479
So we want to group like oh, I think now we can use the copy thing.
01:28:20.640 --> 01:28:24.079
Uh oh, it's probably it's probably the wrong argument order.
01:28:24.479 --> 01:28:27.600
Imagine is does J have a regex engine inbuilt?
01:28:28.640 --> 01:28:30.159
It looks it looks the same.
01:28:30.319 --> 01:28:34.239
I don't know how to use the key here correctly on the indices.
01:28:34.319 --> 01:28:38.960
We want to we want to group the indices, but how do we supply what the keys are?
01:28:39.279 --> 01:28:42.479
If there's a J uh programmer uh in the chat.
01:28:42.800 --> 01:28:53.439
I mean there was one earlier, but um Have they explored the approach to only use the index of first and index of the element in the vector.
01:28:55.039 --> 01:28:58.560
I'd fill up the dot after slash uh for key.
01:29:01.520 --> 01:29:04.000
Okay, yeah, so these are all the indices, right?
01:29:04.159 --> 01:29:06.960
And so instead of the this is the enclose.
01:29:07.199 --> 01:29:10.079
So I think marble we'll come back to what marble command is.
01:29:10.319 --> 01:29:12.720
Okay so here inside here we want well, okay.
01:29:12.800 --> 01:29:14.479
It does the parenthesis thing for me.
01:29:14.640 --> 01:29:16.239
We want to do the first and the last.
01:29:16.319 --> 01:29:18.079
Is there there's a head and tail?
01:29:18.399 --> 01:29:21.199
Yeah, it's uh brace colon and brace dot.
01:29:21.760 --> 01:29:25.520
Open brace and yeah, open brace dot.
01:29:26.000 --> 01:29:27.039
Uh this.
01:29:27.359 --> 01:29:29.359
Uh it's actually the last one we want, right?
01:29:29.600 --> 01:29:31.039
Last minus first.
01:29:31.279 --> 01:29:34.159
Yeah, I can never remember which is which, but you know, you just you just switched.
01:29:34.239 --> 01:29:34.560
There we go.
01:29:34.720 --> 01:29:36.399
You try both and one of them will work.
01:29:36.880 --> 01:29:37.600
Exactly.
01:29:37.760 --> 01:29:38.239
There you go.
01:29:38.399 --> 01:29:42.399
So now we we now we got this far, and now we just want to do the minimum on this.
01:29:42.720 --> 01:29:43.279
Right.
01:29:43.600 --> 01:29:49.600
So the minimum is X less than dot, but we can't we have to cap it.
01:29:49.920 --> 01:29:50.720
No, that's not right.
01:29:50.800 --> 01:29:52.800
We don't want to do the minimum, we want to do the maximum minimum.
01:29:54.640 --> 01:30:00.399
And then we want to do we want to um subtract one from this.
01:30:00.560 --> 01:30:04.560
So negative one plus, or we can decrement, which doesn't help anything.
01:30:04.960 --> 01:30:06.079
Just more caps.
01:30:06.399 --> 01:30:12.079
We could technically speaking glue it together with decrement over here, with decrement minus dot or something.
01:30:12.399 --> 01:30:13.279
I don't know.
01:30:13.600 --> 01:30:17.359
Uh decrement is wait, hold on.
01:30:17.600 --> 01:30:19.119
Uh less of that.
01:30:19.680 --> 01:30:20.319
Decrement.
01:30:20.560 --> 01:30:21.920
Less than colon.
01:30:22.079 --> 01:30:23.119
Of course it is.
01:30:26.880 --> 01:30:27.680
Of course it is.
01:30:27.920 --> 01:30:29.840
Uh and that was not right anymore.
01:30:29.920 --> 01:30:30.399
I don't know.
01:30:30.560 --> 01:30:32.239
I can't read this stuff.
01:30:32.640 --> 01:30:34.640
I mean we got the we get the impression.
01:30:34.800 --> 01:30:40.079
Oh, we got the the bulk of the colons because they got like the combinator.
01:30:41.760 --> 01:30:44.399
Yeah, it's got extra colons for good order.
01:30:45.199 --> 01:30:49.199
See if you're on a ray box, you could have just gone control space and typed in decrement.
01:30:49.359 --> 01:30:50.960
You never need to memorize anything anymore.
01:30:51.279 --> 01:30:52.159
Okay, thank you.
01:30:52.479 --> 01:30:54.239
That's uh is that true?
01:30:54.399 --> 01:30:55.760
I'm going on a ray box now.
01:30:55.840 --> 01:30:57.119
Yeah, well, I'll steal it back to the box.
01:30:57.840 --> 01:30:59.359
This was interesting, right?
01:30:59.520 --> 01:31:06.880
Because this means that in J, this solution was so much better, the one like so much nicer as well.
01:31:07.359 --> 01:31:08.079
Actually read that.
01:31:08.239 --> 01:31:23.439
Now I'm gonna I want to go back to APL for a moment because if you look at um this in G, we could actually well it doesn't actually matter because this is the this is the last index.
01:31:23.600 --> 01:31:34.399
Sorry, and I'm gonna by the way, I'm working on a new keyboard solution for dialog APL, and I'm gonna steal APL space as a default shortcut for a keyword search.
01:31:36.640 --> 01:31:37.520
It's control space.
01:31:37.840 --> 01:31:39.520
Well, it's depends what you want.
01:31:39.680 --> 01:31:42.880
Uh your maybe it will just be settable to whatever you want.
01:31:43.119 --> 01:31:43.359
Yeah, yeah.
01:31:43.520 --> 01:31:45.760
And I I wasn't the one that came up with it.
01:31:45.840 --> 01:31:48.239
It's it's on, I think CAP has a version of it.
01:31:48.319 --> 01:31:55.439
There, you know, I everything on Array Box is just an amalgamation of all the best things across every single REPL in all the different array languages.
01:31:55.840 --> 01:31:56.239
For sure.
01:31:56.560 --> 01:32:01.199
So so just what I what I thought of here is an APL is sort of nice to do an inner product here.
01:32:01.279 --> 01:32:02.319
I don't know if you like that.
01:32:02.399 --> 01:32:03.760
It's just it's not shorter.
01:32:03.920 --> 01:32:09.199
It's just because it's a reduction over mixed effective, like you could do it.
01:32:09.359 --> 01:32:15.359
It would be nice if if we had like a yOTA dot whatever, like an index of last.
01:32:16.159 --> 01:32:19.439
Um all right, can I steal it back to show marble comas?
01:32:19.600 --> 01:32:20.960
Yeah, good technically credits.
01:32:21.279 --> 01:32:23.600
Uh I'm gonna pronounce this wrong, but I'll do my best.
01:32:23.760 --> 01:32:27.359
Adrax uh has a optimal Wiwa solution.
01:32:27.439 --> 01:32:36.239
And seeing as we we don't have the J representative, we don't have the Wi WA representative, we're just doing our best to showcase all the different uh array languages.
01:32:36.479 --> 01:32:48.960
So if we come here and um so yeah, this just to you know highlight on screen what I was mentioning, if you're in J or whatever you wiwa and you don't know how to type it, I mean in wiwa, you can just you know type the name of it.
01:32:49.039 --> 01:33:01.199
So you don't really need this, but uh you you know you can do stuff and and find it, which a lot of the times there's a subset in J and in BQN and definitely in Tiny Apple that I do not know how to type.
01:33:01.359 --> 01:33:10.159
Um anyway, so this is the optimal from by way of marble coma or or by from Adorax by way of marble coma in the YouTube chat.
01:33:10.239 --> 01:33:18.960
So this is the benefit of doing this on YouTube is uh we can fill in our lack of expertise in the array languages that we're not good at and uh borrow them from them.
01:33:19.039 --> 01:33:31.359
So I believe this is classify in um WeWah, and then this is unselect, which actually I don't I don't have the log is classify, bro.
01:33:31.920 --> 01:33:33.279
So do they have it?
01:33:33.600 --> 01:33:37.920
So I don't have the name of this, but there's a bunch of idioms that I scraped from the Wiwa docs.
01:33:38.399 --> 01:33:41.359
Uh and they have names, I think, half the time.
01:33:41.520 --> 01:33:45.840
So unselected, or like I don't know what it corresponds to, but this is an idiom.
01:33:46.000 --> 01:33:48.479
Um what I can I not get rid of this.
01:33:48.720 --> 01:33:52.239
And then we have, I believe this is complement or not, as they call it.
01:33:52.479 --> 01:33:58.079
Plus, uh this is minimum, and then unselect this enumerate an array, right?
01:33:58.239 --> 01:33:59.600
Oh, yeah, totally.
01:33:59.920 --> 01:34:00.239
What am I doing?
01:34:00.479 --> 01:34:02.399
Yeah, let's just let's just get rid of this.
01:34:02.640 --> 01:34:03.119
Get rid of this.
01:34:03.840 --> 01:34:04.399
Unselect.
01:34:04.800 --> 01:34:09.359
I can just uh yeah, we would have been able to see this if I just evaluated this like this.
01:34:09.439 --> 01:34:11.920
So yeah, it's enumerate zip with index basically.
01:34:15.279 --> 01:34:16.960
In front because it's stack based, right?
01:34:17.199 --> 01:34:18.079
It's stack based.
01:34:18.239 --> 01:34:20.159
Oh a lot of things are backwards, right?
01:34:20.239 --> 01:34:30.640
Like every every function including uh binary operations are are prefix and uh so something's no diode, it's stack based, right, right, right.
01:34:30.880 --> 01:34:34.159
And then if you do not, ooh, actually, that's interesting.
01:34:34.640 --> 01:34:40.640
The not of your indices is actually one minus.
01:34:40.960 --> 01:34:41.680
Is that right?
01:34:41.920 --> 01:34:43.039
Did I just do that correctly?
01:34:43.439 --> 01:34:44.239
One minus, yeah.
01:34:44.399 --> 01:34:49.840
And so because you have zero index, it's one zero, negative one, negative two, negative three, negative four.
01:34:50.479 --> 01:35:06.479
And if we Oh, and then you add those together then that is like subtracting the indices from the last from the indices from the first from the beginning, indices of the last from indices of the first.
01:35:07.279 --> 01:35:08.079
Breaking my brain.
01:35:08.399 --> 01:35:10.239
No, no, I yeah, it's there.
01:35:10.880 --> 01:35:13.039
So classify totally makes sense.
01:35:13.199 --> 01:35:17.760
If you have the string ABC C V A, you get 012210, that's fine.
01:35:18.239 --> 01:35:31.119
Unselect zips with the indices, then you take the complement or not of the indices, and that's effectively programmed as one minus, which uh Yeah, that's that comes from BQN.
01:35:31.199 --> 01:35:37.840
It was because of fuzzy logic, that the the pro the probability of something not happening is one minus the probability of something happening.
01:35:38.079 --> 01:35:39.600
So that's why not is one minus.
01:35:40.000 --> 01:35:50.800
But in this case, it you ri you end up your indices are transposed to or not transposed, transformed to one zero, negative one, negative two, negative three, negative four.
01:35:50.880 --> 01:36:01.680
And then when you add that transformed index sequence with your classify sequence, you end up for the case of ABC C B A 11102 negative four.
01:36:02.000 --> 01:36:03.520
No, you're right, I'm lost again.
01:36:03.760 --> 01:36:05.760
Yeah, and then whether that makes sense.
01:36:06.000 --> 01:36:07.600
Uh or what it's for.
01:36:08.159 --> 01:36:13.840
So it's and then and then so there is an absolute value at the end, which might make more sense if we do that.
01:36:14.239 --> 01:36:15.279
No, it's the distance.
01:36:15.359 --> 01:36:21.359
It's the distance to the uh actually wait, but you need it to be in front because they're doing a minimum here.
01:36:23.920 --> 01:36:26.239
This is if we go back to the plus, go back to the plus.
01:36:26.319 --> 01:36:29.359
I'm pretty sure that's the distance from this element.
01:36:29.520 --> 01:36:31.199
Can you stick another C on the end?
01:36:32.560 --> 01:36:33.439
Is that the distance?
01:36:33.520 --> 01:36:37.840
So that C is three characters away from the first C.
01:36:38.159 --> 01:36:41.119
And the A is four characters uh one, two, three, four.
01:36:41.199 --> 01:36:43.039
Yeah, four characters from the first A.
01:36:43.359 --> 01:36:45.760
And the B is two characters from the first B.
01:36:45.840 --> 01:36:51.359
But the first C is uh does that make sense?
01:36:51.520 --> 01:36:52.640
One, one, one, zero.
01:36:53.039 --> 01:36:56.319
I think C is zero characters from the previous C.
01:36:56.800 --> 01:36:59.520
Well, there are zero characters in between that and the previous C.
01:36:59.600 --> 01:37:04.399
And the second one, there are three characters between that C and the very first C.
01:37:04.800 --> 01:37:16.000
Yeah, yeah, because the property of the classify, similar to what Adam was talking about earlier when we were doing the uh Dyadic Iota selfie, is that it's the first index.
01:37:16.159 --> 01:37:19.760
It's not just like the category, it's not just the label, it's the first index of it.
01:37:19.920 --> 01:37:27.279
And so if you do this, I mean it's still a little bit mind-bending that No, but that's it, right?
01:37:27.359 --> 01:37:29.680
That's giving you the Yeah.
01:37:29.920 --> 01:37:38.239
It's it's just a little bit mind-bending because the transform index sequence, it's not zero to negative six, it's one zero and then negative one to negative five.
01:37:38.399 --> 01:37:51.840
But when you add that to the classify, you get back basically a maybe off by one distance from the character to the first instance of that character.
01:37:52.000 --> 01:37:52.239
Yeah.
01:37:52.479 --> 01:37:54.720
Which happens to be exactly what we want.
01:37:54.960 --> 01:38:00.800
And then the the confusing part is that you have to go minimum and then absolute value.
01:38:00.960 --> 01:38:05.039
I mean minimum absolute value is just is it is it though?
01:38:05.199 --> 01:38:10.000
Because uh just negate uh Madeline says you need to negate.
01:38:10.319 --> 01:38:14.319
Otherwise, in that when they're all different, it's probably negate.
01:38:14.479 --> 01:38:16.239
Otherwise, when they're all different, you get it wrong.
01:38:16.319 --> 01:38:18.399
If you do absolute, then negative one becomes one.
01:38:18.560 --> 01:38:19.279
You don't want that to one.
01:38:19.439 --> 01:38:19.840
Yeah, yeah, yeah.
01:38:21.119 --> 01:38:21.520
Alright.
01:38:22.479 --> 01:38:23.039
Wild.
01:38:23.520 --> 01:38:25.520
J with ligatures sounds amazing.
01:38:25.840 --> 01:38:33.680
J with ligatures sounds like actually why did this one oh yeah, because I I put in stacks instead of min.
01:38:34.720 --> 01:38:43.439
So technically, I guess, yeah, I guess this would be a lot longer in because there's no zip width index.
01:38:43.680 --> 01:38:50.479
I mean you could spell it with range pair, but you're gonna need at least uh a before or a fork.
01:38:50.880 --> 01:38:52.159
It has classify.
01:38:52.640 --> 01:38:56.159
So I mean actually, let's see, let's see how if I go to BQM, which I believe is right above.
01:38:57.279 --> 01:38:57.760
Translate.
01:38:58.159 --> 01:39:05.600
So this is you know, classif classify, and then this is what uh let's just comment this out for the moment.
01:39:05.680 --> 01:39:06.479
Is that gonna work?
01:39:07.039 --> 01:39:09.600
Um, I didn't mean to get rid of everything.
01:39:09.760 --> 01:39:14.720
So we have classify, and why I guess this needs to be in a fork.
01:39:20.319 --> 01:39:20.800
Oh right.
01:39:20.960 --> 01:39:22.880
There needs to be a there needs to be a length in here.
01:39:23.680 --> 01:39:24.960
Alright, so this looks right.
01:39:25.119 --> 01:39:28.319
So here's our classify sequences on the right down here.
01:39:28.560 --> 01:39:34.960
And then now we have our uh enumerate, except we don't actually want to enumerate, so we just want this actually.
01:39:35.199 --> 01:39:40.560
Um now we want to do our complement, if I can type that correctly.
01:39:40.720 --> 01:39:43.279
And now we want to do was it plus?
01:39:43.439 --> 01:39:45.439
Oops, I got rid of something I should have gotten rid of.
01:39:47.520 --> 01:39:54.159
Then the pattern was we want a min reduce and an absolute value, which is absolutely negate, not absolute.
01:39:54.720 --> 01:39:55.840
Negate, not absolute?
01:39:56.159 --> 01:40:03.680
Yeah, because if they're all different, negative one becomes I can't remember the explanation, but it's it should be minus.
01:40:03.840 --> 01:40:07.439
Oh right, but then uh I'm so close.
01:40:07.680 --> 01:40:11.039
This is right, I need uh nothing before this.
01:40:11.199 --> 01:40:11.760
There we go.
01:40:11.840 --> 01:40:13.520
And so can this be golfed?
01:40:13.680 --> 01:40:17.039
Um looks pretty tight to me, I don't know.
01:40:17.199 --> 01:40:22.319
Uh yeah, you can a little bit because you can flip you have a fork on the right, right?
01:40:22.399 --> 01:40:24.159
But it's parenthesized left side.
01:40:24.560 --> 01:40:28.800
Don't we still need to use something we'd need to or I guess maybe just glue them?
01:40:29.520 --> 01:40:30.319
Oh, just glue them.
01:40:31.600 --> 01:40:33.039
Another term, another turn.
01:40:33.439 --> 01:40:33.840
Oh yeah.
01:40:33.920 --> 01:40:37.359
I I I I fail to so fork brained.
01:40:37.520 --> 01:40:47.520
Um I mean to be fair, like passing wise, I like I personally like grouping, you know, bits and parentheses, even when I write frames and stuff.
01:40:48.000 --> 01:40:48.880
He wanted it to go off.
01:40:50.640 --> 01:40:57.840
I mean, I I I agree that like you know, if I'm writing it in code, I probably would have I probably would have left it like that because this is much more I agree with Rich.
01:40:58.000 --> 01:40:59.359
It's much more impenetrable.
01:40:59.600 --> 01:41:04.319
Well you gotta figure out like uh the there's two jots there, and one of them's doing one thing and the other one's doing well.
01:41:04.479 --> 01:41:06.000
I guess it's not, but it is.
01:41:06.239 --> 01:41:06.880
I don't know.
01:41:07.119 --> 01:41:14.880
I wonder if someone like Marshall, like if he instantly sees this and then knows like that's a unary function and that's a fork, or I don't know.
01:41:15.279 --> 01:41:16.560
What what are you guys are the pros?
01:41:16.800 --> 01:41:19.039
Like, uh I guess Rich, you said yet it's still hard to parse.
01:41:19.119 --> 01:41:19.760
What about you, Adam?
01:41:19.840 --> 01:41:20.640
Like, do you instantly see these?
01:41:20.960 --> 01:41:36.079
Yeah, yeah, I've gone over the other side of tacit and uh less of a I see I sort of see those screws together, but it bothers me that things that are adjacent with no combinator between them are more distant from each other than things that are uh that are bound together.
01:41:36.399 --> 01:41:43.680
So people are saying in the chat that you know that uh J with ligatures might be interesting.
01:41:44.159 --> 01:41:50.640
Uh I'm thinking valuable concepts uh it still spans the width of two characters though.
01:41:50.720 --> 01:41:52.079
So I don't know what we're talking about here.
01:41:52.159 --> 01:41:56.239
Like it didn't have to, it could be it could be variable width, right?
01:41:56.399 --> 01:42:01.359
Is it so no but I'm thinking about that the ligature changes two characters into a single character?
01:42:01.520 --> 01:42:02.239
Is that possible?
01:42:02.720 --> 01:42:07.119
Yes, yeah, yes, you have, but you never notice because those are not coding fonts, right?
01:42:07.279 --> 01:42:09.119
Yeah, because any normal fonts are enough.
01:42:09.199 --> 01:42:12.319
I'm talking about Jeffrank mono and and sibling fonts that have ligatures.
01:42:12.640 --> 01:42:18.319
If you write F lowercase F, lowercase j in the normal font, it puts the F and the J together.
01:42:18.399 --> 01:42:19.760
That's where ligature comes from.
01:42:19.920 --> 01:42:21.600
Using it for programming is a heck.
01:42:22.319 --> 01:42:25.199
Um so or FI, right?
01:42:25.279 --> 01:42:26.239
It's a classic one.
01:42:26.479 --> 01:42:32.960
Anyway, so maybe like for code for API code, I don't mind so much it being variable width.
01:42:33.279 --> 01:42:35.600
For arrays, they need to be monospace.
01:42:35.760 --> 01:42:38.239
But let's just say there was a way to make that all work out.
01:42:38.479 --> 01:42:50.800
Imagine if the spacing between the glyphs was larger when there was no combinator between them, but then the combinator was like narrow and like pulled them together so they would sort of look nicer, sort of healing.
01:42:51.039 --> 01:42:51.439
Yeah.
01:42:51.680 --> 01:42:54.560
I guess yeah, I'm kind of I'm kind of code golf brain.
01:42:54.720 --> 01:43:06.000
So my my desire is that like when you have if you if you're trying to replace one plus or uh you know some equivalent with increment, it's like well what did I what did I actually do there?
01:43:06.079 --> 01:43:14.399
It's only useful if you need some tacit thing and it saves you like you know a cap or whatever because you can keep things in some you know fork mode or whatever.
01:43:14.640 --> 01:43:21.039
Um but like yeah, tiny apple is much, much better in my opinion, because it's a single Unicode symbol.
01:43:21.279 --> 01:43:33.039
Anyways, have we have we missed there's been a bunch of um comments in the YouTube chat as we wind things down, seeing as we're a full half hour past the 90 minute mark.
01:43:33.199 --> 01:43:36.479
I like how Rich was we gotta share the tiny apple.
01:43:36.560 --> 01:43:38.880
We were it's at 83 minute mark, and then boom.
01:43:39.119 --> 01:43:41.920
Oh, I didn't realize there was a desire to keep it at 90.
01:43:42.239 --> 01:43:46.479
Oh, I think I have a uh was that established at the in the first five minutes when I wasn't here.
01:43:46.880 --> 01:43:49.760
Ever since ever since the beginning of a rake catch, there's supposed to be 90 minutes.
01:43:50.000 --> 01:43:53.680
I can kind of yeah, I well yeah, but I did kind of look at the also the links.
01:43:54.000 --> 01:44:01.840
No, I didn't have a a final uh entry here, which is writing Perl in APL, basically.
01:44:02.079 --> 01:44:04.880
Solving this using regx in dialogue APL.
01:44:04.960 --> 01:44:06.479
No, the wrong tool for the job.
01:44:06.560 --> 01:44:07.359
Let's do it.
01:44:07.920 --> 01:44:08.319
Yeah, yeah.
01:44:08.640 --> 01:44:09.119
All right.
01:44:09.279 --> 01:44:09.600
Okay.
01:44:10.239 --> 01:44:14.239
Although my wife said uh I've got two minutes, so hopefully you can do this in two minutes.
01:44:14.640 --> 01:44:16.159
I can I think so.
01:44:16.399 --> 01:44:17.840
So so I think this works.
01:44:18.000 --> 01:44:20.960
I haven't made it into a single function, although that shouldn't be hard.
01:44:21.039 --> 01:44:23.439
It I think it just it just comes out to a train.
01:44:23.680 --> 01:44:24.720
So we can do that.
01:44:24.960 --> 01:44:26.399
But it looks completely insane.
01:44:26.720 --> 01:44:27.520
Yeah, that okay.
01:44:27.600 --> 01:44:42.079
So so what's happening here is essentially this is the search function, and it's looking for any one character followed by any number of characters, and then a back reference to the first same character again, which is what we're looking for, right?
01:44:42.319 --> 01:44:52.880
So any sequence that begins and ends with the same character, and we don't care whatever is in the middle, and it's greedy, so it wants to make them as long as possible, but we want to catch overlapping matches.
01:44:52.960 --> 01:44:57.039
So this is the variant that says open overlapping matches is set to one.
01:44:57.359 --> 01:45:09.359
And we don't actually want the result of the search, we just want to know the length of the result, which is the code one for the result instead of returning a text, we return that over there.
01:45:09.439 --> 01:45:15.039
So I'll I'll shorten this for a moment just over here and and use the uh and symbol.
01:45:15.279 --> 01:45:17.760
This gives us all the matches that it could find.
01:45:17.920 --> 01:45:25.039
If we add some more like some B's in here, so we can see that we find the maximum A up here to B, right?
01:45:25.279 --> 01:45:28.000
So these are all the possibilities, all the candidates.
01:45:28.239 --> 01:45:31.199
But we don't want the that, we just want the length of each one.
01:45:31.359 --> 01:45:32.720
So we replace this with a one.
01:45:32.960 --> 01:45:34.319
So this is length eight.
01:45:34.560 --> 01:45:40.960
And then we want to subtract, but remember this counts the length of the first and the last character included.
01:45:41.039 --> 01:45:43.600
We only want actually the length of of the middle one.
01:45:43.760 --> 01:45:50.880
So we could extract the middle one, but it's easier to just uh to just subtract one from it here.
01:45:51.359 --> 01:45:53.119
Um is that actually true?
01:45:53.199 --> 01:45:55.039
Is that the shouldn't we subtract two?
01:45:56.159 --> 01:45:58.319
Let's make a shorter example just to see here.
01:45:58.640 --> 01:46:02.159
So this should give us yes, oh, it gives length two.
01:46:02.319 --> 01:46:10.000
So we need to subtract two over here, and then there's one problem that is if there aren't any uh matches, we need to get negative one.
01:46:10.239 --> 01:46:15.680
So if I if there aren't any matches, it gives us an empty list, and then we try to do the maximum empty list, that's no good.
01:46:16.000 --> 01:46:20.159
Uh because that gives us the identity element, which is negative infinity, so we don't want that.
01:46:20.560 --> 01:46:24.560
Um actually, and we could be trickery with this, but whatever.
01:46:24.720 --> 01:46:27.920
So this is the uh this gives us three, one, two, three.
01:46:28.000 --> 01:46:29.119
That's this one over here.
01:46:29.279 --> 01:46:33.920
And if there aren't any matches, we get negative one because I just stuck that in there.
01:46:34.239 --> 01:46:37.119
The problem is we get inf negative infinity.
01:46:37.520 --> 01:46:38.960
So there is something we could do here.
01:46:39.039 --> 01:46:45.199
We could be a little bit tricky and just say like negative one with maxed with that, but that's just that's just silly.
01:46:45.359 --> 01:46:47.359
Uh it doesn't save save us anything.
01:46:47.520 --> 01:46:54.079
Anyway, so this is a uh this is a solution uh using ragex in dial like APL.
01:46:54.159 --> 01:46:55.279
Forget you ever saw this.
01:46:55.359 --> 01:46:56.079
Don't do this.
01:46:56.239 --> 01:47:00.319
This is for sure going to be the slowest solution of them all, and it only works on characters.
01:47:00.560 --> 01:47:02.479
So uh yeah, never mind.
01:47:02.640 --> 01:47:04.800
You will also fail and all kinds of other things.
01:47:04.960 --> 01:47:06.239
Well, now you've seen that.
01:47:06.560 --> 01:47:07.279
There we go, folks.
01:47:08.640 --> 01:47:09.520
We should call it a day.
01:47:09.600 --> 01:47:12.000
He didn't do it in two minutes, but three and a half is pretty good.
01:47:12.079 --> 01:47:15.600
And uh doing Pearl better than Pearl uh you know does it.
01:47:15.680 --> 01:47:24.399
Technically, you know, this problem came from Pearl Weekly Challenge, but every once in a while I look at the Pearl solutions and they they try and make it look like Python and like very variables all over the place.
01:47:24.479 --> 01:47:30.560
And uh I tried to find the solution, they don't have it, but I the solution for the first one is like hardly using regex at all.
01:47:30.720 --> 01:47:34.720
So APL, doing Pearl better than Pearl, and I guess that's where we'll leave it.
01:47:34.800 --> 01:47:36.000
So we saw what did we see?
01:47:36.079 --> 01:47:39.760
We saw uh we saw some J, we saw some APL, we saw some Tiny Apple, we saw some Wiwa.
01:47:40.000 --> 01:47:44.159
We did see a little bit of BQN at the end too, and uh the only thing we didn't see is Cap.
01:47:44.399 --> 01:47:48.079
So I guess we gotta bring Ellias on or something to make up for that at some point.
01:47:48.319 --> 01:47:53.119
Uh thanks to Adam and Rich for um hopping on and and chatting about this.
01:47:53.199 --> 01:48:02.560
I think this honestly turned out so much better than not that I thought it was gonna be bad, but I didn't think it was gonna be one of our like, you know, better episodes of covering a bunch of different primitives and solutions.
01:48:02.800 --> 01:48:07.920
If folks have their solutions, uh post the live recording of this.
01:48:08.079 --> 01:48:10.560
Feel free to share them in the the YouTube comments.
01:48:10.720 --> 01:48:14.800
You can also reach us at arraycast contact at arraycast.com.
01:48:14.960 --> 01:48:18.319
If we have access to the email, we I think we kind of quasi got blocked out.
01:48:18.479 --> 01:48:20.000
Adam I need to figure that out.
01:48:20.079 --> 01:48:21.359
Uh we should have continued.
01:48:22.239 --> 01:48:28.560
Luckily, uh you can log into the YouTube account uh without having to log into the Gmail first.
01:48:28.640 --> 01:48:32.880
So I was worried we lost access to the YouTube account, but we still have access to that.
01:48:33.039 --> 01:48:34.479
Uh once again, thanks.
01:48:34.640 --> 01:48:39.039
And I guess with that, we will say happy array programming programming.
01:48:39.439 --> 01:48:42.399
Uh it's been a while.
01:48:42.960 --> 01:48:44.159
Happy array programming.
01:48:44.239 --> 01:48:45.680
I didn't know you can do it at the same time.
01:48:45.760 --> 01:48:46.159
It doesn't matter.
01:48:46.399 --> 01:48:51.600
No, no, the way we do it at the same time is that when he says that we'll say, that's when you have to say happy array programming.
01:48:51.760 --> 01:48:57.680
Yeah, yeah, but back in the day, in the old days, it was he'd say it and then everyone would say it.
01:48:57.760 --> 01:48:58.000
Yeah.
01:48:58.159 --> 01:49:00.800
And if we didn't even say, that's because you would fix it in post.
01:49:01.840 --> 01:49:03.359
But now we're live, things are different.
01:49:03.680 --> 01:49:04.640
Anyways, thanks guys.
01:49:04.720 --> 01:49:06.319
We'll uh we'll do this again sometime.
01:49:06.640 --> 01:49:07.039
All right.
01:49:07.680 --> 01:49:08.560
Great to see you.