back to indexFast.ai APL study session 13
00:00:10.000 |
The site, but if anybody has any resources for signal processing in APL, I'd be interested. 00:00:25.440 |
I did a quick search, but I didn't do an exhaustive one. 00:00:28.160 |
So, like I said, I'll put something up on the site. 00:00:31.120 |
But feel free to add something in the chat if anybody knows anything. 00:00:35.840 |
>> It might be worth searching for the kind of things you would use for signal processing, 00:00:43.280 |
like look on APL Wiki and stuff like Fourier transform or Kalman filter. 00:00:59.600 |
>> Okay, so I remember we were up to auditioned in close. 00:01:25.280 |
>> Has anybody skipped ahead to figure out what that is? 00:01:40.240 |
>> What button do we press for in close again? 00:02:07.140 |
>> Oh, so for me, it seems like it was doing, say, if on the left-hand side you have 1, 2, 3, 00:02:16.880 |
it would enclose the first one one time at like three elements on each side, 1, 2, 3 on each side. 00:02:24.080 |
>> Well, could you explain maybe the version we've got here? 00:02:32.160 |
I mean 0101, let me make sure it does what I think it does. 00:02:40.080 |
>> So it's giving us 23 in the first cell and four in the second cell. 00:03:05.840 |
Yeah, I played with it a bit and thought I knew what it did. 00:03:19.280 |
It's looked like the ones are defining groups. 00:03:22.800 |
So it's taking where the first one is and giving us the numbers there, 00:03:29.920 |
the letters in this case, then the second group is defined here, the letters there. 00:03:42.000 |
This is the first time I've- >> Okay, I was just looking it up 00:03:45.600 |
in the background and I think it's starting to explain basically what you were saying. 00:03:52.880 |
>> It looked like it was a pretty good definition at least starting out. 00:04:31.600 |
The APL Wiki example's a bit clearer, I think. 00:04:47.200 |
Okay, so then they're saying some dialects by which I assume they mean dialogues included. 00:04:58.480 |
Okay, so that's just saying create two partitions, make this the second. 00:05:05.680 |
Have two partitions after the first and then three partitions after that. 00:05:17.120 |
All right, well, that seems straightforward enough. 00:05:27.760 |
Looks like the next one is left shoe underbar. 00:05:48.000 |
Which is written as shift C, I guess, right, shift C, okay. 00:06:35.920 |
>> It has some, it's kind of like enclosed with some 00:06:39.840 |
extra logic so that it doesn't nest too many times. 00:06:43.280 |
If you nest and nest and nest, it doesn't do that. 00:06:49.920 |
>> Okay, let's have a look at this example, shall we? 00:07:05.040 |
And so this adds up how many times an A appears in each word? 00:07:20.080 |
Okay, it's counting out the words, no worries. 00:07:25.120 |
it'll count the A's in each letter because it's going H, yes. 00:07:48.080 |
I quite like that they're saying like an example of why it would be useful in API Wiki. 00:08:09.200 |
Now that's the same as normal and close, right? 00:09:31.280 |
I think simple means that it's an array that doesn't contain any arrays. 00:09:38.160 |
So I think if we did two, three, reshape, iota six, that's the same because this is simple. 00:09:54.000 |
I don't know, I didn't type down where I got the definition, but a simple array is an array 00:10:00.400 |
of depth one with all primitive values such as a string or array of numbers. 00:10:04.480 |
Oh, perfect. By the way, what happened to our thing that shows like the little squiggle 00:10:10.720 |
or thing that tells us, you know, the end shows us that it'll arrows. 00:10:20.000 |
Okay, I think that tells us whether something's simple. 00:10:36.720 |
So if I do this, that's considered, so I think squiggle might mean simple. 00:10:54.160 |
All right, great. So if it's just a, so basically if it's just an array, 00:10:59.360 |
like, or tensor, I guess, then it's gonna return it unchanged. 00:11:20.080 |
If it's an array, then it encloses it. Is that what it's saying? 00:11:36.560 |
Okay, so they're right, right, so that's enclosed. 00:11:46.960 |
Okay, so they're the three possibilities, so I guess we should show them. 00:11:53.360 |
And left shoe would have done the same thing, no? In fact, I just tried it on sleep. 00:12:01.760 |
Right, a left shoe does the same in the case of an array, 00:12:08.160 |
but not in the case of a scalar or a non-simple object. 00:12:16.400 |
So that's why you can see here, this is the same. 00:12:41.760 |
Okay, so in the case of a scalar, right, enclosed does nothing. 00:12:55.520 |
Okay, so they're exactly the same in the scalar case and the simple array case, 00:13:01.760 |
but they're different in the nested array case. 00:13:08.560 |
If it's already a nested array, it doesn't nest it anymore. 00:13:28.480 |
So then, dyadic is partition rather than partitioned in close. 00:13:54.400 |
It's something about that the partitions are now defined in a different way, 00:14:10.960 |
Therefore, an element is greater than the nape and it's left. 00:14:46.320 |
So here is a place where it's gone down and therefore it's gonna skip the fourth element, 00:14:54.240 |
And then this here goes up again, so it's gonna create a new partition, a new group. 00:15:08.480 |
I guess maybe a good time to talk about forks because their example here is a fork. 00:15:50.320 |
>> It does make sense, but it seems like it's quite involved to what it can do. 00:15:57.440 |
And the differences between the operators that we've seen here on close. 00:16:01.840 |
I'm just curious how much of this was in the original specification of APL, 00:16:10.640 |
So essentially, how much of this is coming from the CANI person's paper? 00:16:22.640 |
>> Yeah, I assume this classic edition thing would be closer. 00:16:25.680 |
There is a APL dictionary on the J software website, 00:16:30.560 |
which I guess would be a good place to answer that question. 00:17:15.120 |
>> So the way he arrived on this was even without, 00:17:17.760 |
before he, there was no implementation initially, right? 00:17:26.160 |
So this was well after there was an implementation. 00:17:42.960 |
So that was a point when there wasn't an implementation. 00:17:47.120 |
>> And I think this would be interesting too, 00:17:48.560 |
cuz this is where they actually designed IBM computer systems 00:17:56.320 |
>> Yeah, this sounds like a very interesting read. 00:18:14.640 |
designed at kind of high school level, if I remember correctly. 00:18:22.160 |
>> Let's see, one semester pre-calculus course, yeah. 00:18:35.200 |
>> So he worked with the Fox Lane High School teachers. 00:18:42.960 |
>> So yeah, it's like kind of normal stuff, circular functions, inverse, reciprocal, 00:19:03.840 |
>> The environment or where this was devised and- 00:19:11.760 |
>> Although interestingly, he's got superscripts here. 00:19:18.080 |
>> Which is not what we're using nowadays, we're using star. 00:19:24.240 |
Although these reductions are the same, and he's got subscripts, that's also interesting. 00:19:39.680 |
So anyways, so yeah, it starts off by talking about programming stuff, 00:19:58.560 |
Yeah, the J software website, jsoftware.com/papers has, yeah, a lot of, 00:20:06.560 |
they seem to spend a lot of time scanning in and even though CRing a lot of stuff. 00:20:17.760 |
>> I guess we can do the second example, can we? 00:20:20.560 |
>> Yeah, so that's why I was saying we're gonna do forks next. 00:20:34.400 |
Okay, so we've already talked about one fork. 00:20:36.240 |
So the basic kind of idea that Adam said that maybe we can steal it directly. 00:21:00.880 |
Oh, maybe it was after the last study session. 00:22:15.120 |
And so here we've got f plus g where f is reciprocal and g is exp. 00:22:24.160 |
And so according to his example, that should be the same as 00:22:54.720 |
So first applies this to three, then it applies this to three, 00:23:27.680 |
>> I think we might be in the situation where we cannot see the- 00:23:34.480 |
>> There's a function, there's a function, there's a function. 00:23:38.320 |
So make sure you put this operator with the function on its left. 00:23:43.280 |
Plus slash, there's the middle function, there's the right hand. 00:23:47.440 |
So that's f, that's g, and that's what we're using instead of plus, using divide. 00:24:03.360 |
So that is equal to two plus five plus eight plus nine divided by four. 00:24:16.320 |
So plus slash of 2589 divided by tally of 2589. 00:24:24.000 |
And so something that's very interesting about this is that if we defined a function, 00:24:27.840 |
and this is something that Aaron Shue talks about in his ArrayCast 00:24:32.480 |
interview, we could define a function called mean. 00:24:46.480 |
And so the interesting point though is that the word mean has the same number 00:24:56.960 |
So why define a function for this, rather than just use the definition anytime you 00:25:05.600 |
want to use it, because that way you're being more explicit. 00:25:12.960 |
because it actually tells you exactly how to do it. 00:25:15.840 |
So it's a totally different way of thinking about software engineering is, 00:25:20.400 |
yeah, not to create abstractions when you end up with an interaction 00:25:26.320 |
where the number of letters in its name is the same as the number of characters in its definition. 00:26:06.480 |
So this one, which is a little thing pointing rightward, there's that, yeah, okay, backslash. 00:26:31.280 |
Okay, this is called right tack, which makes sense. 00:26:48.000 |
And monadic is called same, and it's what we would normally call the identity function. 00:27:18.080 |
Diatic is called right, and it always returns its right argument. 00:27:35.520 |
Okay, and I am pretty sure that left tack will do the exact opposite. 00:28:03.840 |
Starting to get the hang of the mnemonics for the letters now. 00:28:12.080 |
Generally you shift to get the kind of the other version of the same thing. 00:28:54.560 |
Which, okay, this one here might help to see each bit separately first maybe. 00:29:33.920 |
H of f, oops, f and j past the left hand side and the right hand side. 00:30:01.280 |
That's just gonna return the right hand side. 00:30:36.640 |
Then the right hand side, which I don't have to put in parentheses, but I'm just going to. 00:30:47.120 |
Because this fork means that the left hand side and the right hand side are passed to this. 00:30:57.920 |
So this fork is something that will separate the string by spaces. 00:31:06.880 |
And again, you could, well, not just by spaces, but by whatever's on the left. 00:31:13.120 |
So we could create a function for that called split. 00:31:18.320 |
But the name of the function will actually be more characters 00:31:21.440 |
than the three characters it takes to define it. 00:31:34.160 |
Wouldn't it be more readable to use alpha and omega in such cases? 00:31:41.920 |
I mean, everything's cryptic when you don't know it, right? 00:31:46.800 |
I mean, if you do any work with math notation, in math notation, it's very cryptic. 00:31:58.880 |
So yeah, sure, it's very cryptic when you don't know it. 00:32:05.120 |
I think it's error than alpha and omega once you know, 00:32:11.520 |
because there's less to, at least for me, less to keep in my head. 00:32:17.040 |
So the alpha and omega version, if you didn't want to do a fork, would be. 00:32:55.920 |
>> You essentially have to do this in your head, if you want to, if I, right? 00:33:11.840 |
I think once you get comfortable with abstractions, you kind of don't. 00:33:20.880 |
I feel like this version, you have to do it in your head. 00:33:26.240 |
For this version, I think you could read it as, like, fairly directly in English as, 00:33:32.880 |
what's this name of this character, dyadic, I don't quite remember, whatever it is, match, 00:33:39.040 |
So it'd be like, you know, you could say, like, I should actually say the right words. 00:34:14.880 |
You know, I think that's probably something that one could become comfortable 00:34:26.400 |
It reminds me of your surprise the other day when I mentioned, you know, my daughter 00:34:29.600 |
found it to understand APL than the normal math notation. 00:34:35.200 |
But, like, I think we're just kind of, like, reflecting our own years of studying, you know? 00:34:42.160 |
I actually think, yeah, so, I don't know, like, I'm not an APL speaker by any means, so. 00:34:54.080 |
All right, I think that's super interesting anyway, it's fun. 00:35:01.680 |
Like, it's interesting research to kind of think about this alternative notation and 00:35:05.600 |
what it might mean to be comfortable with it. 00:35:08.000 |
And, you know, hopefully my daughter will teach me. 00:35:25.920 |
I'm gonna do them before partition and stuff because I want to segue into fork. 00:35:38.800 |
So, we're using forks and trains interchangeably, or trains are- 00:35:46.800 |
So, trains just refer to a bunch of functions next to each other with no other punctuation. 00:35:52.080 |
So, a train, you know, an example of a train would be the one that we did for the power operator. 00:36:26.960 |
Function, operator, function, operator, function. 00:36:31.440 |
So, I guess this is a function and then this is an operator and this is a function. 00:36:37.200 |
Another example of a train would be- >> We did a two train today. 00:36:50.240 |
>> Yeah, it was, I think, under dyadic partition. 00:36:55.440 |
>> The one that you copied from, oh, here, line 31. 00:37:17.920 |
>> This is a three train, which is called a fork. 00:37:21.280 |
>> Yes, that's why we're- >> Right, so you're looking for a two train. 00:37:26.000 |
I just want to come up with an example of a two train. 00:37:27.840 |
So, a two train, for example, two trains are much easier to understand because they're 00:37:35.040 |
So, if we did to the power of the reciprocal, we don't even need that, right? 00:37:49.360 |
Then it's going to just, you just read right from it, one over three, e to the power of that. 00:37:54.000 |
Right, so that's the same as- >> No special rules, right? 00:38:02.480 |
And in the dyadic case, then like that, then I believe it does three divided by 00:38:11.760 |
three first, and then does e to the power of that. 00:38:15.040 |
So, that's going to be e to the power of one. 00:38:24.480 |
So, that's going to be three to the power of the third, which will be the cube root of three. 00:38:44.960 |
It would be the same as- >> Three on both sides. 00:38:49.440 |
>> It would be the same as putting three on both sides. 00:38:54.000 |
So, Adam's point is that we don't need a special thing for hook because we can always use- 00:39:09.840 |
We can put it there or we can put it on the other side to say, yeah, or you can use total diuresis. 00:39:20.640 |
So, yeah, I think trains are just bunches of functions next to each other. 00:39:25.280 |
Okay, so let's do the arrows, which I do see a lot. 00:39:38.640 |
Presumably, they're going to call this up arrow. 00:40:07.840 |
All right, and it's called, oh gosh, what's this again? 00:40:20.320 |
Does anybody know why one would change this quad ML thing? 00:40:26.560 |
I remember it refers to kind of like the version of the language or something. 00:41:01.520 |
It looks like it's doing the opposite of that. 00:41:12.320 |
It seems to kind of go the opposite direction before, didn't we? 00:41:29.040 |
So, this is going to be, so the shape of this is going to be two, three. 00:41:49.120 |
Does anybody remember how to go from the matrix to the 00:42:40.240 |
That's not going to be the same thing because you want to actually 00:43:44.880 |
An array whose items may be uniform in rank and shape or they might differ. 00:44:00.800 |
Let's ignore the non-uniform case for a while. 00:44:03.200 |
So then R is an array composed of the items of Y 00:44:07.840 |
assembled into a higher rank array with one less level of nesting. 00:44:16.960 |
So we started out with a rank one array and we got a rank two array. 00:44:23.760 |
So the depth used to be true and I guess the depth is now one. 00:44:26.640 |
If I remember the definition of depth correctly. 00:44:29.520 |
If they have different ranks, each item is extended in rank 00:44:35.360 |
to that of its greatest rank by padding with leading ones. 00:45:14.160 |
So this would get padded to become a one element vector. 00:45:54.160 |
So that's what they're saying is being done implicitly. 00:46:06.320 |
Okay, so if they're different ranks, you get the ones. 00:46:08.720 |
Okay, then I got different shapes, which they do. 00:46:10.560 |
So now each is padded with the corresponding prototype. 00:46:15.680 |
I think that a prototype is the kind of like base default value of a type. 00:46:26.240 |
I wish these kind of things had hyperlinks though to definitions. 00:46:36.080 |
So in other words, we could do the same thing by doing it manually. 00:47:04.480 |
Yeah, so if anybody can figure out how to go from the matrix back to the 00:47:07.840 |
array of arrays more conveniently than my ugly version, let me know. 00:47:16.480 |
You can do it by providing access to the shoe operator. 00:47:29.040 |
So although Adam's told us to kind of avoid access, but there we go. 00:47:37.920 |
Hang on, I'm trying to go the other direction. 00:47:57.600 |
Okay, so what this is going to do is it's going to be 00:48:00.480 |
a three by three matrix containing one, two, zero, three, zero, zero, four, five, six. 00:48:06.880 |
And I don't think these parentheses are needed, are they Molly? 00:48:31.280 |
In other languages, I think we'd call this head. 00:48:39.920 |
I love that they don't create more functions than needed. 00:48:46.960 |
Okay, so that just takes the first n characters or the last n characters. 00:49:41.360 |
Let's just start with, okay, what if we do that? 00:50:19.360 |
So this is going to grab the first two rows of the matrix. 00:50:24.560 |
And this is the first two rows and the last three columns of the matrix. 00:50:28.480 |
Okay, so here's a nice easy way to index into contiguous sections of an array. 00:50:38.320 |
So two minus three is going to be the first two rows, last three columns of this bit here. 00:50:48.560 |
Well, now I'm curious about what the other arrow is going to be. 00:50:52.640 |
Oh, one other thing was taking more than the amount that was in the array. 00:51:15.280 |
Oh, I think that's going to be called its prototype. 00:51:17.040 |
And for the matrix, you're going to get zeros. 00:51:23.920 |
So yes, I think the space is the prototype for a character and zero is a prototype for a number. 00:51:35.280 |
Have we missed anything else, Molly, or you think that's it? 00:51:40.320 |
Um, well, in the case of, oh, here's an example that I wanted to share. 00:52:37.680 |
because that sounds like a weird edge case that people can figure out, 00:53:05.840 |
Presumably, if I type down here, I'm going to get the down arrow. 00:53:08.960 |
The down arrow does the thing that you wanted to do. 00:54:12.160 |
There's still a lot of symbols we haven't done. 00:54:44.800 |
Oh, well, actually, I'm not sure what this is going to do. 00:54:49.520 |
Everything except these is something of a weird shape. 00:55:05.200 |
And none of the last three columns means you're left with this. 00:55:22.080 |
Okay, those sound like very useful things to know about. 00:55:41.760 |
Before the symbols, I will encourage other people to try to do the competition. 00:55:48.800 |
Serato, did you use the arrows much in your competition? 00:56:08.000 |
Excuse me, but is the competition available again? 00:56:24.160 |
So I'm wondering if the competition is back available again for this year, the 2022. 00:56:31.680 |
I don't know, but based on the test case they show in the screen, 00:56:37.120 |
you should be able to try working on it as well. 00:56:46.320 |
But when you submit, you'll find out they actually have more edge case in the test, 00:56:55.680 |
I can always do it previously as one, as Serato mentioned before. 00:57:04.800 |
So combining, trying to do the competition with looking at the forums after a couple of tries, 00:57:13.600 |
that sounds like a really nice way of learning this stuff. 00:57:17.680 |
I don't see a way to see the current year's ones, because it tells you... 00:57:34.640 |
But last time they have the PDF done, maybe I can post it. 00:57:43.040 |
Yeah, and then you can just space on the test case. 00:57:45.280 |
They only have four test cases, and then at least you have some time return to work on. 00:57:51.360 |
Or alternatively, maybe post a notebook or something with the questions,