back to indexFast.ai APL study session 17
Chapters
0:0
3:30 Recursion
4:21 Guard Expressions
5:25 Guard Expression
00:00:49.000 |
Assuming I got them the right way around, I always forget which triangle is which. 00:01:07.000 |
One question is, how do I write it upside down triangle. 00:01:43.000 |
You have them turn on your keyboard. I guess so. Yeah, I didn't even know old G was bound to something. 00:01:51.000 |
Oh, it's Google Google Drive seems to have stolen that hot way that's control all G. 00:02:09.000 |
There we go. Why do I keep getting this may help. Now I wonder, let's change. 00:02:23.000 |
Maybe go right upside down triangle. Actually that might only be in here. 00:02:40.000 |
For recursion. So maybe we'll try a PL wiki then. 00:03:42.000 |
I think that'd be something about recursion in here. 00:04:06.000 |
Okay, so there's actually a couple of things to note here. 00:04:15.000 |
Because we haven't done guard expressions either. 00:04:45.000 |
How do we write diamond back to back to back to back to with my keyboard. 00:04:59.000 |
So factorial is to find such a factorial of Omega equals factorial of Omega minus one. 00:05:16.000 |
And so here's an example of a factorial if we wanted to write it ourselves, and the thing that's new here. 00:05:25.000 |
Is this thing here, it's got a guard expression. 00:05:33.000 |
And if it is and it exits with this return value. 00:05:39.000 |
So in this case factorial of five. This is not true. So then this is a statement separator. 00:05:45.000 |
So said it's going to return five times factorial of four. 00:05:51.000 |
And then factorial of four will do the same thing will be four times factorial three and so forth until it gets to factorial of one. 00:05:57.000 |
And this will be true. So that's our base case it will return one. 00:06:14.000 |
You can't. I think you want to use each. You may. Yeah. 00:06:32.000 |
Probably if we're somewhere to do this as a tacit function. 00:06:39.000 |
Maybe we wouldn't have the problem. Not sure. 00:06:42.000 |
Okay. Does that make sense to guard expressions. 00:06:50.000 |
So what if we wanted to define it and use it. 00:06:58.000 |
So if we wanted to define factorial and then immediately use it. 00:07:02.000 |
That's not going to work because this function doesn't have a name. 00:07:06.000 |
So you need to be able to refer to the current function. 00:07:31.000 |
It's different from the selfie isn't it. So different from the selfie yes so selfie selfie simply. 00:08:22.000 |
So we're calling it with let's start by calling it with two. 00:08:31.000 |
I make it equal to it's not less than or equal to one. So skip this. 00:08:36.000 |
So it's equal to two times the current function of one. 00:08:42.000 |
This is the current function. So it goes to do this with one. 00:08:46.000 |
Yes that is less than or equal to one. So it returns one. 00:08:59.000 |
So it's exactly the same as the factorial one I've just replaced the word fact. 00:09:14.000 |
In Python for example if you want to create a recursive function you can't create a recursive Lambda. 00:09:25.000 |
But in APL you can create an anonymous recursive function. 00:09:38.000 |
So we could also cause to find this as fact if we wanted to. 00:09:46.000 |
Like we don't have to make it anonymous or it still work fine. 00:10:07.000 |
Anyone you suggest we do next or should we just randomly pick something. 00:10:16.000 |
I think maybe it can go through all the boxes together. OK. 00:10:20.000 |
Do you have any sense of what the boxes are vaguely about. No. 00:10:28.000 |
The second one. Yeah. I think that is the current. 00:10:33.000 |
I think that is the pin out the second one. So but the rest I don't know. 00:10:38.000 |
Does that this quad. Yeah. Cool. OK. Well we we've already done quad. 00:11:01.000 |
I'm guessing they don't have something called quad with to be at top. 00:11:21.000 |
I don't see it. Maybe we'll search the wiki or something. 00:11:28.000 |
It's purple rather than blue which makes me suspicious. Maybe it's not a thing. 00:11:42.000 |
Quote quad. Oh that's the name of the newsletter. 00:11:46.000 |
It's named after the left quote quad which can be used to print text. 00:12:07.000 |
Oh OK. So quad is standard output and quote quad is standard input. 00:12:43.000 |
Oh hello. Yeah Jupiter input input through through it is not supported. 00:12:49.000 |
OK OK but we could do is like get something from student in a script or something. 00:12:56.000 |
Yeah I think if we did a script it would be supported. 00:13:02.000 |
Here they're just using it as a normal variable I guess. 00:13:08.000 |
It's the array is displayed without the line ending. Oh that's interesting. 00:15:23.000 |
So basically even though it's not going to work I would do. 00:16:30.000 |
So probably not really part of our notation. Although I guess it's useful to know what it's talking about. 00:16:44.000 |
So I think knowing how to use JSON is nice. How do we create this character matrix. 00:17:28.000 |
This is I guess we could just go 1 2 3 4 5 6 2 3 4 5. 00:17:40.000 |
So wait. Do we use double quotes or single quotes. We use single quotes. 00:18:01.000 |
OK so if we did 1 2 3 4 5 6. So four rows of six columns. 00:18:42.000 |
Oh Jeremy I saw at the mention using the square back and then the input for multi line but I haven't tried in Jupiter. Maybe we can try. 00:18:55.000 |
Hang on. Hang on. Hang on. I'm not quite sure. Let me let me come back to you. 00:19:24.000 |
Oh I see that one's got a comma and that one doesn't. OK. 00:19:28.000 |
So we can do six and then you can tell me about this multi line idea. 00:19:40.000 |
OK sorry. I put it in the chat. Maybe you can copy me at the at the top of the multi line. 00:20:16.000 |
And do you think I might then be able to like 00:21:13.000 |
It's funny they're using this rather than the usual quad gets thing. 00:22:58.000 |
And what's the name of the symbol just called variant is it. 00:25:08.000 |
Tick back tick. Now that's time and how do I forget that. 00:25:27.000 |
We're definitely getting to some of the weird ones huh. 00:25:57.000 |
I think this is what we can use for like convolutions and stuff. 00:26:27.000 |
Hey it's working on fast Kaggle and I totally lost track of the last couple 00:26:33.000 |
I looked up and I was like oh it's halfway through the session soon. 00:26:46.000 |
You haven't missed much as we've only been doing weird ones. 00:27:41.000 |
Yes it does sound a lot convolution a lot like a convolution. It's going to be applied to possibly overlapping rectangular views of the right. 00:28:09.000 |
It's back to a dictionary of APL which we saw the other day. 00:28:27.000 |
Okay so we're going to pass it two rows. The first row is the dimensions of the rectangles and the second is the movement which I guess is like the stride. 00:28:46.000 |
The right argument has an upper end as rank Y columns. 00:28:53.000 |
Okay so you're going to be saying for each access. 00:29:11.000 |
As you can use fewer. We'll worry about that special case later. 00:29:45.000 |
Okay so this is starting. Okay this looks like a good way to do it. 00:30:30.000 |
I'm confused as to why they used to do fun for it. 00:31:13.000 |
It's making it's ensuring it's monadic I guess it's what it's doing. 00:31:25.000 |
It just seems like a really clunky way to do that. 00:31:43.000 |
Well, maybe stencil put something on its left. 00:31:58.000 |
Okay, just a tick. I gotta go check on my daughter. 00:32:13.000 |
Without the nest it doesn't keep the shape of the input, so like it becomes kind of a list. I don't know. That's all I found so far. 00:32:25.000 |
So if we add the assignment to the materialize, you know, both with the defund, and then without. So if we do the left arrow to materialize. 00:32:56.000 |
I don't think I know these parentheses, but I guess I meant right between the defund and the stencil. So then we can see what is going into the function and then if we take away the defund we can see what's going into the enclosed. 00:33:21.000 |
Okay, I don't know if that makes sense though. I'm not sure if it does right because the thing on the left of the stencil is the function. That's right, which is a defund. 00:33:33.000 |
And we do kind of know what it is because we can see it's been printed. 00:33:38.000 |
Oh, you know what we could do is we could do alpha comma. 00:34:31.000 |
We use the statement separator to enclose Omega and material and print alpha, or do two statements in that defense. 00:34:54.000 |
Yes, so we are getting alphas, which presumably this documentation will tell us. 00:35:11.000 |
So F F is invoked diatically and the vector left argument indicates the number of fill elements that's useful. 00:35:28.000 |
Okay, so you can see that for this first one we've got fills along the top and left. 00:35:35.000 |
Hence the one one and then for the next one we've got to fill along the top only. 00:35:45.000 |
Yes, it's the top right and one negative one. 00:36:12.000 |
I'm still trying to think of the convey, you know, the tacit way to just turn something into a monadic function. 00:38:35.000 |
So that's, first of all, applies this function to Alpha and Omega. 00:38:43.000 |
And then it applies this function, which is obviously much uglier than the. 00:39:13.000 |
of this array and passing it to this function. 00:40:17.000 |
If there's somewhere to get nice images and stuff onto a PLG but a notebook so it would be cool to do like just a simple Gaussian blur kernel or something to display this. 00:40:42.000 |
the way that was recommended to get images and it's to convert your images beforehand the bitmaps and then loaded them. Okay. 00:40:54.000 |
there's a section on images in the mastering dialogue APL PDF that I haven't gone through yet, but it's going to look there but. 00:41:08.000 |
Yeah, kind of everyone at PNG is the same, but pretty much. 00:41:16.000 |
There's a bitmap. Oh, no, you can use gift for PNG. 00:41:26.000 |
Okay, well, I never got the PNG is working right but. 00:41:48.000 |
it's been several projects where people do like neural nets on images, using minced. 00:41:54.000 |
And I'm not sure the format that they're in, they're behind a young look on young with guns website, but it's password protected so I can't actually see the data set but. 00:42:12.000 |
Ask if he's willing to share what that data set at some point but it looks like it's just minced in some format. 00:42:24.000 |
Yeah, maybe you should send them a message and ask. 00:42:37.000 |
This is doing both. This is actually probably better. 00:43:14.000 |
Anybody I presume there's an APL stencil version of game of life. 00:44:35.000 |
It's like, it's not quite linear algebra, just not quite sure where to put this. 00:44:43.000 |
And now I guess we'll call it other other lifts, other function, other operators. 00:45:13.000 |
One of those hydrants is an execute statement. 00:45:16.000 |
I think that's the first one second one third one. 00:45:51.000 |
I can't imagine that's going to come up too often so we can definitely put that in the. 00:46:03.000 |
I think that triangle is self reference for recursion. 00:46:13.000 |
Yeah, we did that a little bit earlier just before you arrived, I guess. 00:47:01.000 |
Actually as it would be executed by the monadic execute primitive function. 00:47:48.000 |
Yeah, it's a good idea that way we're not overlapping. 00:47:54.000 |
Not available on Mac. Well, I'm not on my max that's okay. 00:48:07.000 |
We have more officially available wouldn't it. 00:48:12.000 |
That was it occurred. Why do we use chat wizards. 00:48:42.000 |
Services include SVD probability probability distributions. 00:49:04.000 |
So then this is going to be our execute expression thing as well. 00:49:28.000 |
Oh, no, sorry. There's another one that forks a new process. 00:49:37.000 |
Oh, I see. There's a, there's a fork thing in the. 00:49:40.000 |
Yeah. Yeah. I was still reading through them. Sorry. 00:49:54.000 |
Can somebody tell me the keyboard shortcut for this one. 00:51:37.000 |
Is the result of the last executed sub expression. 00:51:44.000 |
The non shy results of all proceeding expressions are displayed. Okay. 00:53:54.000 |
That is what I've been following it until I just looked it up. 00:54:59.000 |
So the only way you can tell these different is from the lack of the 00:55:08.000 |
I thought there's supposed to be dots between the four, 00:55:41.000 |
So, so I think it's converted to a string of characters. 00:56:55.000 |
I put this in the weird lift section as well. 00:58:30.000 |
But it can create monadic and dyadic function. 00:58:35.000 |
You can tell because of the curly brackets on the X. 00:58:47.000 |
Okay. This is replacing two and four with zero. 00:59:01.000 |
Oh, you can replace it with a function call. That's neat. 00:59:07.000 |
Okay. So this one's replacing two or four with zero in iota five. 00:59:21.000 |
And I'm guessing this is replacing two and four with times applied to the right hand side and 10. 00:59:48.000 |
Oh, and you can also use a function on the right hand side. That's neat. Okay. 00:59:51.000 |
So this can be the array for placement or the function to be applied and the left argument is X call. 01:00:54.000 |
Oh, yeah, this is what replacing replacing two gets replaced with three and four gets replaced with one. 01:01:36.000 |
Okay. There's all kinds of weird indexing things that we haven't talked about. Choose indexing or reach indexing. 01:01:50.000 |
Okay. So this is the monadic version of the function one. 01:02:00.000 |
Replace with reciprocal and positions two and four. 01:02:10.000 |
Oh, I like this. Replace odd elements with zero. 01:02:16.000 |
So two, there are two modulo two, this basically means. 01:02:44.000 |
What does this mean? Replace odd items with themselves reversed. 01:02:59.000 |
That's clever, isn't it? It's actually applying it to the whole array and then deciding which elements to replace. 01:03:31.000 |
Okay, let's move this into the main operator sections. It seems really useful. 01:04:07.000 |
So we will move this section out of the way because it's less interesting. 01:04:51.000 |
Okay, it's superseded by more modern control structures. So maybe we should not really spend much time on that. 01:05:00.000 |
I think we should do it in the weird section. 01:06:04.000 |
like bash basically spawns it in the background. 01:08:10.000 |
I don't think that's worth spending time on particularly, so I don't think we're going to be using APL as our main parallel programming tool. 01:09:02.000 |
Okay, I don't think that's the thing about this one. 01:09:45.000 |
All right. Well, if people feel motivated, then I think we should, you know, start adding crows to these notebooks. 01:10:01.000 |
If any of you decides to do that, what I suggest you do is open an issue in the APL study repo and say, I'm working on crows for this notebook. 01:10:19.000 |
That way, people will know not to do the same notebook to avoid doubling up. Does that make sense? 01:10:34.000 |
What do you think, or have you planned out what what you're going to work on what we're going to work on in the next session or are these continuing I guess that's the first question. 01:10:49.000 |
Yes, stop this week so there won't be one tomorrow. 01:10:56.000 |
And my plan is to switch to some nb dev sessions. 01:11:07.000 |
Probably come back to it after part two of the course. 01:11:14.000 |
Yeah, in the meantime if anybody's, you know, got a really good Anki deck that covers all the glyphs, I would love a copy of it. 01:11:25.000 |
So at least I don't forget what I've learned. Did you have you been kind of keeping up with adding the glyphs to your Anki deck. 01:11:38.000 |
Perhaps that I think I run it, it will be updated I haven't been updating it all the time but I probably do quite a bit of editing though, because not everything's very Anki friendly, you know, it'd probably be a good starting point, like. 01:11:54.000 |
Yeah, particularly if you like spits out a CSV or something like that you could open up in a spreadsheet and then you could just like delete the rows that don't make sense or combine some or something important. 01:12:05.000 |
Right now it's the books for those looking. We will see how consistent the structure is but I did handle some ed cases around looking for markdown cells that are at least a certain number of header like a header three or above and it looks for the back 01:12:25.000 |
of the text afterwards. I think you've been pretty consistent with that scheme so yeah recently it's just like there'd be a bunch of cards that aren't necessary and some that don't really stand alone and some which like have too many examples and, you know, but yeah I mean that 01:12:42.000 |
would be a great, great start we could certainly use. 01:12:54.000 |
Yeah, no hurry. Otherwise we're all going to forget everything. That's for practicing. 01:13:09.000 |
That's some kind of a deck of symbols from the dialogue docs so yeah be useful to add the mnemonics to that too if you have time to or anybody else has time to. 01:13:25.000 |
Otherwise we're just going to have to look them up. 01:13:29.000 |
Okay, well thanks for sticking with me to the end. 01:13:38.000 |
And yeah anybody interested in nb dev, probably, probably start doing the same time next week, see how things go. 01:13:46.000 |
After next week Monday, Monday US Tuesday Australia. Yeah. Oh, right.