back to index

Fast.ai APL study session 15


Chapters

0:0
2:27 Screen Sharing
26:57 Create a Column Vector
70:20 Transpose
77:8 Triple Copying
79:55 Random Number Generation

Whisper Transcript | Transcript Only Page

00:00:00.000 | [ Silence ]
00:00:28.000 | >> Hi Jeremy.
00:00:34.000 | >> Hi there.
00:00:35.000 | >> How are you doing?
00:00:42.000 | >> Pretty good, thank you.
00:00:43.000 | [ Silence ]
00:01:02.000 | >> So you have installed your monitors up high?
00:01:05.000 | Is that good?
00:01:06.000 | >> I've got two monitors.
00:01:17.000 | I've got one monitor split into two halves.
00:01:24.000 | >> I'm always curious where your monitors are because you look up all the time.
00:01:28.000 | Oh, you have two stacked, is it?
00:01:31.000 | >> It's one monitor, but it's in P by P mode, so it's treated.
00:01:37.000 | >> Okay, that makes sense.
00:01:41.000 | I have a tall monitor, a wide monitor as well.
00:01:44.000 | Maybe you can do that.
00:01:46.000 | >> Yeah, so this one's specifically designed for what they call P by P, or picture by picture mode.
00:01:53.000 | >> I was designing the picture.
00:01:56.000 | >> So I've got it plugged into the computer with two cables.
00:02:00.000 | So the computer thinks there's two monitors connected.
00:02:04.000 | So I could move you guys down to the bottom.
00:02:08.000 | Okay, and now I'm looking down at you.
00:02:12.000 | >> That's more like you.
00:02:15.000 | >> But now it's in the way of where I want to type APL.
00:02:19.000 | And it's also -- that's the screen.
00:02:22.000 | So I share the bottom screen.
00:02:28.000 | So I put you guys on the top screen.
00:02:32.000 | >> Now I know.
00:02:40.000 | >> Hi, Rory, welcome.
00:02:42.000 | Are you able to talk or be videoed, or are you just on text chat today?
00:02:57.000 | Just text chat, I guess.
00:03:00.000 | That's what I am.
00:03:01.000 | Okay, no worries.
00:03:02.000 | I don't want you to disturb people.
00:03:05.000 | All right.
00:03:06.000 | Well, since today is an extra -- rather late announced extra session, it might just be the four of us.
00:03:14.000 | So cool.
00:03:17.000 | That's fine.
00:03:18.000 | How are you, Isaac?
00:03:25.000 | >> I'm doing good.
00:03:28.000 | Yeah, I wasn't sure I was going to be able to make it today, but I was able to wrap things up.
00:03:33.000 | So happy we're doing an extra one today.
00:03:36.000 | >> Yeah.
00:03:37.000 | Thanks for coming.
00:03:40.000 | >> Thanks for hosting.
00:03:57.000 | >> Thank you.
00:04:26.000 | >> I haven't done this big O diuresis before, or have we?
00:04:29.000 | >> We have.
00:04:30.000 | >> Did we have already in operators?
00:04:32.000 | >> Yeah, we did.
00:04:33.000 | >> We did.
00:04:34.000 | Okay, that's terrible because I forgot.
00:04:39.000 | In that case, I will add an explanation of something I just played with.
00:04:43.000 | Okay, here we are.
00:04:44.000 | Circle diuresis, dyadic.
00:04:48.000 | >> That's the rank thing.
00:04:49.000 | Oh, well, there are two versions of it.
00:04:51.000 | One with the big O and one with the small O.
00:04:53.000 | >> Yeah, this is the big one, the circle, as opposed to jot.
00:05:16.000 | >> Circle diuresis.
00:05:23.000 | I don't think we've done the dyadic form of the function that it creates.
00:05:34.000 | Oh, yes, we have.
00:05:35.000 | >> Yeah, that's not in one.
00:05:49.000 | It's one over to the score.
00:05:52.000 | Two to the one-third.
00:05:54.000 | >> Okay.
00:06:07.000 | This one is increasing of both arguments.
00:06:28.000 | That doesn't seem quite correct, then.
00:06:31.000 | So the reason I'm asking is I was trying to do the permutations function.
00:06:38.000 | Which is, so if I wanted to do P 10, 4, that would be that.
00:06:59.000 | That is right, six.
00:07:08.000 | So that is lamp, lamp, lamp.
00:07:16.000 | What's lamp?
00:07:19.000 | >> A comma.
00:07:21.000 | >> What's the mnemonic, then, for the lamp?
00:07:27.000 | >> No, actually, Adam posted it.
00:07:29.000 | It looked pretty helpful.
00:07:31.000 | It leads to a bunch of mnemonics on the forum.
00:07:39.000 | >> Adam replied to the session 14 with answers to pretty much everything.
00:07:44.000 | One of which is basically, Jeremy, stop forgetting things.
00:07:47.000 | Look up the mnemonics with a link to the page.
00:07:56.000 | This will be bottom row keys.
00:08:00.000 | Similar to the words comma and comment.
00:08:02.000 | Okay.
00:08:04.000 | That's fine.
00:08:17.000 | >> I've been doing the Anki every day, and that's been helping quite a bit.
00:08:21.000 | >> Yeah, I haven't been doing any extra study at all because I've been doing the nbdev stuff.
00:08:26.000 | So my APL is four hours a week for this, plus a bit of stuff with my daughter and her friend.
00:08:34.000 | So it's not really enough to remember.
00:08:42.000 | Okay, so rec 1507 reckons that this would do it.
00:08:58.000 | Okay, it does.
00:09:00.000 | So that's interesting.
00:09:03.000 | Oh, yeah, I do see it.
00:09:04.000 | This is what it's doing.
00:09:05.000 | It's doing reciprocal of 2 to the power of reciprocal of 3.
00:09:12.000 | So this is called over.
00:09:14.000 | Okay, so that's awesome.
00:09:23.000 | I knew there'd be something, I just didn't have time to quite figure it out properly.
00:09:42.000 | So an interesting exercise for the reader would be to create a version of this test set program that does the 10 minus 6 part as well.
00:09:56.000 | Because the definition is actually, actually we could write it out here.
00:10:01.000 | It's really that, right?
00:10:09.000 | Sorry.
00:10:13.000 | Okay, that's useful review.
00:10:31.000 | So then another useful review, which I'm not going to do now, is, well, A, Adam pointed out upper and lower tack with higher rank arguments and explained why and how that works in a way which somebody probably should put on the APL wiki, if anybody feels up to it.
00:10:51.000 | It looks really great.
00:10:54.000 | And also talked a bit about, oh, yeah, this train that we had trouble with.
00:11:00.000 | Which honestly, the thing he ended up coming up with is really no better than the defund anyway, which is fine, but still useful exercise.
00:11:08.000 | And he said he's proposing an operator that actually does preprocess the left hand side rather than the right hand side, which would be nice, which he's calling B, for example.
00:11:21.000 | And that would do exactly what we wanted. That would be a nifty operator because, yeah, without it, it's quite ugly.
00:11:31.000 | And yeah, also some discussion about the Booleans, which the most interesting part being the point that you can think of and as just being times and you can think of not as just being one minus, which I do all the time outside of APL.
00:11:46.000 | And if you do that, then all of the other things come out quite naturally.
00:11:53.000 | Although I didn't know they're called the Morgan's laws.
00:11:57.000 | OK, so.
00:12:07.000 | And I was not smart enough to post in a list of the things we're covering, so let's do that.
00:12:22.000 | Is it in here somewhere? Yes.
00:12:39.000 | OK, so we've done the exclamation mark, we've done the tax, we've done less than and greater than, we've done these, we've done this.
00:12:54.000 | We've done this, right? Yeah, we've done that.
00:13:01.000 | And this is just Josh, isn't it? Or is that Diamond? Can't quite tell.
00:13:10.000 | Yes, Diamond, we've done that.
00:13:15.000 | Did we do Diamond?
00:13:18.000 | I thought so. It's just a statement separator.
00:13:22.000 | I think we've talked about it. I don't remember us putting it in a notebook anywhere.
00:13:27.000 | OK, where did we discuss how to create functions? Is that in the first one?
00:13:45.000 | Under that, there we go, function.
00:13:52.000 | Well, we should put it here then. OK, so.
00:14:10.000 | Anybody know how to type the Diamond?
00:14:17.000 | I think it's the back tick.
00:14:23.000 | You're right, double back tick.
00:14:26.000 | Oops.
00:14:29.000 | That's no good.
00:14:37.000 | Broken help.
00:14:51.000 | Now you got to search for what the name of what it does.
00:14:56.000 | Uh-huh, which is.
00:15:00.000 | It doesn't even show up in my toolbar.
00:15:03.000 | Does it for you?
00:15:05.000 | It looks like a very small dot if you don't have a great font.
00:15:25.000 | You guys search for statement separator.
00:15:30.000 | You found it?
00:15:32.000 | There's a page on it in the dialog box. I don't see it in the wiki yet.
00:15:42.000 | What should I search for?
00:15:46.000 | It's called Under.
00:15:49.000 | It's in the link here.
00:15:52.000 | The different section, the defined function section.
00:15:56.000 | Yeah, I found that it's in Tran funds though, it seems like a weird place for it.
00:16:05.000 | You can't find in the appeal because it's not just using Tran funds, but OK, maybe that's just where they happen to put it.
00:16:20.000 | All right, fine.
00:16:24.000 | I don't know what it is anyway.
00:16:30.000 | Oh, I see. Serata said we actually haven't done slope bar because it's the placeholder.
00:16:36.000 | Got it. That's easy fix too.
00:17:06.000 | OK, so we could say F is equal to two things.
00:17:15.000 | First, we're going to calculate A as that and then new statement.
00:17:25.000 | And then we're going to return 2 plus A.
00:17:34.000 | There we go. Makes sense.
00:17:37.000 | That can send me a column, really.
00:17:40.000 | Oh, so it's always the statement on the right side that gets returned. The last thing that it evaluates is returned.
00:17:50.000 | There are some like wrinkles, like there's something called guard expressions, which you can look up in the help.
00:17:59.000 | But yeah, basically, it's like, you know, a lot of languages do this thing. There isn't exactly a return.
00:18:08.000 | Rory campuses. It's not the last thing. It's the first thing.
00:18:12.000 | I don't think that's right. We're returning the last thing. We're returning 2 plus A.
00:18:17.000 | A equals 4 times 2 and then we do 2 plus A and then that's what we return.
00:18:25.000 | OK, so Rory's got one to try, which is slightly different to what we just discussed.
00:18:34.000 | Let's copy it properly.
00:18:57.000 | Cool. OK, that's interesting. So these are different for some reason.
00:19:07.000 | Here we expected three words.
00:19:10.000 | Right. So in this case, it's definitely returning 2 plus.
00:19:20.000 | It's the first non-assignment or Rory put something that's just non-assignment or something like that.
00:19:29.000 | Right. So.
00:19:33.000 | Yeah, OK. That's non-assignment.
00:19:42.000 | Thanks, Rory.
00:19:46.000 | OK, lamp is a comment, which is like a comma.
00:20:06.000 | And then.
00:20:13.000 | Better do a slope bar.
00:20:37.000 | OK, so we haven't quite got it all right here, so.
00:20:58.000 | And this is probably wrong, too.
00:21:05.000 | Yeah, it's called scan. So we're going to fix this.
00:21:13.000 | Scan.
00:21:18.000 | I guess this is then scan first.
00:21:46.000 | So that's all good.
00:21:49.000 | Next.
00:21:55.000 | I think I want to do these ones.
00:21:57.000 | They seem to come up a lot.
00:22:14.000 | Those, I believe, are back to pound and back to take dollars.
00:22:20.000 | So I'm having some trouble hearing you, Isaac.
00:22:27.000 | Say again.
00:22:29.000 | The I guess I was going to say in the short piece for those are back to pound and back to dollar sign.
00:22:38.000 | Oh, pound.
00:22:43.000 | I can't get over the fact you Americans call that character pound. It's the weirdest thing in the world, but I know what you mean.
00:22:51.000 | I would call it shop or up to thought or hash pound is a pound sterling English currency character to my mind.
00:23:02.000 | Gotcha.
00:23:04.000 | But, you know, after spending 10 years in America.
00:23:10.000 | I can, you know, come to terms with the fact that you guys are all crazy. It's fine.
00:23:19.000 | Yeah, I wish I could argue with that.
00:23:25.000 | I don't know the last three or four years.
00:23:28.000 | I got nothing.
00:23:31.000 | No come back for that. Got too much for us. I'm sorry.
00:23:36.000 | There's plenty of nice things about it, though.
00:23:41.000 | I love that it's called grade down and I had it great down. That's pretty straightforward to remember.
00:23:50.000 | Okay.
00:24:05.000 | And the characters called.
00:24:09.000 | Right down. Okay.
00:24:13.000 | Great down with. Okay.
00:24:17.000 | Does anybody know what the hell this does will give you the index locations that would put that list in order that array. Okay.
00:24:31.000 | Got it.
00:24:38.000 | So the weird thing is that they don't actually bother to do the sorting. So, what's the character slash to get the to actually do the sorting to get these I think what's normally done is if you put your array into a variable, then you can just index into your array.
00:25:00.000 | With the sort thing. Yeah, but how do you index into an array. What's the character for that.
00:25:05.000 | You can do it with brackets or the I believe. Yeah.
00:25:10.000 | I thought there's some lift for all power.
00:25:18.000 | All power does it because he creates a major axis. So what does it have arrow. I forget what it's called here.
00:25:27.000 | Right that one.
00:25:32.000 | So, yeah, and there's the
00:25:37.000 | so I'll borrow.
00:25:39.000 | Right. Under.
00:25:43.000 | On. Okay.
00:25:47.000 | Then there's also the, the squash quad but surely, what's one way to do it. So, oh, it's actually doing it in reverse order. Okay.
00:25:57.000 | And you're saying another way to do it would be with up arrow.
00:26:04.000 | On the left, not on the other side of a.
00:26:09.000 | So it'll be up arrow.
00:26:18.000 | And then we can apply sort grade to it. I think I need to run that boxing thing.
00:26:34.000 | Right. Right.
00:26:39.000 | Right. That should create a column victory doesn't say.
00:26:49.000 | why doesn't it.
00:26:57.000 | How do we create a column picture.
00:27:02.000 | Oh man.
00:27:05.000 | We've done it.
00:27:08.000 | I forgot.
00:27:11.000 | Isaac did you have another way of doing it I think he is saying something.
00:27:16.000 | I thought I did that.
00:27:18.000 | Rory put in the chat, there's a way to use.
00:27:23.000 | What's called the squash quad but I don't know if that's what it's actually called.
00:27:27.000 | So you've got to sort idioms one of which was the brackets, but then there's a second way.
00:27:34.000 | Oh, a little, a little square, a little.
00:27:38.000 | Yes here.
00:27:40.000 | Okay.
00:27:42.000 | Materialize.
00:27:45.000 | Materialize. Okay, let's learn this as well now then.
00:27:48.000 | Oops.
00:27:52.000 | Interestingly, and this turned me off for a while is there's actually
00:28:03.000 | a copy and paste from Rory's comment into the notebook while we're here to
00:28:15.000 | do that.
00:28:23.000 | Back to L and back to capital L are slightly different.
00:28:29.000 | One that the index thing and one does the printing on the screen.
00:28:34.000 | Okay.
00:28:43.000 | It's called a squad, not a quad squad means materialize.
00:28:54.000 | If it's an array returns it.
00:28:59.000 | That's what we've been using collection.
00:29:05.000 | Okay so converts object oriented thing. It's basically the same as doing list parentheses in Python, you know, taking with it with an iterator, it's, it's, and that's exactly what we're calling the Python I guess we say we're materializing the iterator.
00:29:24.000 | I guess your items of that.
00:29:35.000 | Alright, so maybe
00:29:39.000 | let's turn up to these.
00:29:42.000 | Okay.
00:30:06.000 | Squad.
00:30:12.000 | I think squad.
00:30:26.000 | I had a squad.
00:30:30.000 | Index, which is exactly what we want.
00:30:34.000 | I assume
00:30:45.000 | God knows how we're going to explain materialize let's see what they do.
00:30:51.000 | Yeah. Okay.
00:30:57.000 | That's a nice example though.
00:31:03.000 | Working with Excel.
00:31:09.000 | So, the works, works, workbook work sheets.
00:31:16.000 | Okay so sheets is an object of this class, but squad is
00:31:36.000 | you see the items in the sheets.
00:31:47.000 | Okay.
00:32:04.000 | Okay.
00:32:30.000 | So the one we care about is index so we've got a matrix okay so two three gives you row to column three.
00:32:44.000 | Right.
00:32:46.000 | And then, it looks like if you enclose it.
00:32:55.000 | We will get multiple ones.
00:32:59.000 | Okay, so.
00:33:28.000 | That's right.
00:33:37.000 | That's right.
00:33:39.000 | The road.
00:33:43.000 | Okay.
00:34:11.000 | Okay, that's what I was expecting. So then if we enclose.
00:34:23.000 | Dammit.
00:34:25.000 | The V.
00:34:30.000 | Oh, okay. I was close. Okay.
00:34:34.000 | ZXC via the
00:34:39.000 | shoes.
00:34:43.000 | No, it's not that.
00:34:56.000 | Oh, inside the friends.
00:34:59.000 | Really.
00:35:24.000 | Oh, that's a quote. Yeah, precedent. Yeah, right, right, right, right, right, right, plus everybody knows that.
00:35:36.000 | Maybe this would be easier if I multiply this by two so we can see it's not just returning whatever I pass it.
00:35:44.000 | Okay.
00:35:51.000 | Right. So now we know the answer to our question.
00:35:56.000 | Did work correctly when you multiply by two.
00:35:59.000 | Return three and one.
00:36:03.000 | Oh, redefine the find it because I'm silly.
00:36:07.000 | There we go.
00:36:08.000 | Thank you.
00:36:13.000 | Okay, so now we can do this.
00:36:18.000 | And we know we can index into a
00:36:24.000 | with the enclosed grade down of a
00:36:32.000 | and I've done that wrong.
00:36:39.000 | Oh, I forgot the squad.
00:36:43.000 | And close grade down and then use that to index into a.
00:36:48.000 | And now how do we do that with a neat tacit thing.
00:36:52.000 | Rory's version is
00:36:56.000 | a defund.
00:37:01.000 | This might be another of those cases where you kind of want the reverse order.
00:37:10.000 | So that's the defund which is fine.
00:37:25.000 | So you want to pre process with that.
00:37:31.000 | And then on the left hand side.
00:37:36.000 | So, if we did the case if we did it the other way around.
00:37:46.000 | And then the children die recess.
00:37:55.000 | And then we shouldn't need the parentheses.
00:38:00.000 | Okay, and so
00:38:07.000 | he's actually going to do another to the artists and get rid of a on the left if you put parentheses around.
00:38:15.000 | Yeah, I don't think it's going to be quite that easy because as soon as well.
00:38:21.000 | Because if you have to the diocese doesn't have a left hand side you put one for you.
00:38:29.000 | I don't think.
00:38:32.000 | Because when you do this because of precedence this is now a train that's treated in a different way. So we've actually got to be careful to put some jobs in here, which is what we just said as well.
00:38:44.000 | So what we want to do is we want to do.
00:38:49.000 | First we do that.
00:38:53.000 | And then we do in close.
00:38:59.000 | This is the right way around though.
00:39:01.000 | It is.
00:39:04.000 | Okay, which is definitely that's less nice.
00:39:09.000 | So we could say, like, sort is that.
00:39:17.000 | And then we could say sort a.
00:39:20.000 | That's a fancy.
00:39:24.000 | That's really fancy, but real.
00:39:43.000 | Rory's got a better one.
00:39:48.000 | You don't need the parentheses.
00:39:52.000 | Well, I think that's interesting let's get rid of things I really want to learn how to pass these things, but I just, I just don't have a sense of how to pass.
00:40:02.000 | That's something we might talk about on the forum is how on earth, you know,
00:40:07.000 | how this is passed.
00:40:11.000 | Rory if you know a link to anything that kind of defines reasonably.
00:40:16.000 | In some detail what these parsing rules are that we could read them to understand why this works, that would be interesting.
00:40:24.000 | Okay, so Rory's got a nicer train.
00:40:30.000 | Which I will call
00:40:35.000 | frame sort.
00:40:56.000 | So this is okay so this is the right hand side.
00:41:01.000 | Okay, so this is function function function.
00:41:04.000 | So this is a fork.
00:41:07.000 | So this first applies to both arguments this is applied to both arguments. So this is just the right hand side. This is a mega.
00:41:16.000 | This is
00:41:21.000 | now in a, oh no in a jot. This whole thing is done monadically.
00:41:28.000 | So this is squad applied to. Oh, this is just squad applied to the pre pre pre processed so this is a mega and great down omega.
00:41:40.000 | And then.
00:41:44.000 | Oh, I guess this all goes first actually because the operator happens first. So that's going to be the same as this I believe.
00:41:54.000 | Yes, very convinced why the same is needed.
00:42:00.000 | What does that do. Yeah, so okay. So this is a fork, a fork is a list of three verbs.
00:42:08.000 | An operator returns a verb. So we've got function operator function so this is the dyadic version of the operator.
00:42:16.000 | There is any data because this operator, it returns a function. Therefore, this is a function. And it's a function which, which
00:42:31.000 | encloses and then grades.
00:42:34.000 | Right, I get that.
00:42:39.000 | So it's kind of backwards to
00:42:42.000 | when we don't use Jot. Oh, he's saying grades and then encloses. Oh, yeah, yeah. Grades and then encloses. So it's the same as not with Jot.
00:42:51.000 | Okay. Grades and then encloses. So you go right to left. That's easier to read. Cool. Good. Okay, I like that. Okay, so there's a function. So function, function, function.
00:43:03.000 | So when you have F, G, H, that's the same as, you know, being applied to alpha and omega.
00:43:19.000 | That's the same as, do they kind of write it like this in, I think it's what they do in OPL, informally at least, that's the same as alpha, F, omega, G, alpha, H, omega.
00:43:45.000 | So we have, so,
00:43:51.000 | enclose, Jot, grade, down is F. So we have F, squad, same.
00:44:00.000 | Well, I mean, diatically, it's actually right hand side. So F, squad, we're going to get F applied to,
00:44:13.000 | oh, and we're calling it monetically. So we just have this.
00:44:25.000 | Okay, so we've got grade, down, then enclose, so omega, A, squad, identity, A, H of omega is omega in this case, right? H of omega is omega in this case, because of same.
00:44:48.000 | Exactly.
00:44:57.000 | Cool.
00:44:59.000 | It's going to take a while for this to become intuitive, but it's all good.
00:45:09.000 | Okay, and then you can do it with axes as well, but we're just learning all the cliffs, so we don't need to do that, because it's not a new glyph.
00:45:23.000 | So hopefully, is there a way to sync the contents?
00:45:31.000 | Nope, apparently not. It's not very useful. Never mind if I say grade up, I think it'll do it.
00:45:46.000 | All right, so presumably this is exactly the same thing, but it's going to effectively sort it.
00:45:53.000 | Oh, and, wait, did we do the dyadic?
00:45:57.000 | No, we have not yet, no.
00:46:01.000 | Well, I guess while we're here, let's do monadic grade up.
00:46:26.000 | Okay, I think that's enough for that one.
00:46:54.000 | Okay.
00:47:03.000 | Provides collating sequence for character data.
00:47:10.000 | Hey, and great damn banana.
00:47:33.000 | Maybe APL Wiki.
00:48:02.000 | Okay, collation order, I see what they're saying. So I think they're saying order in a way where A always comes before N.
00:48:31.000 | Or vice versa, so great down.
00:48:44.000 | So if we said like this.
00:49:06.000 | So this is saying the first element is a capital B, is that right? And then the second element is an N.
00:49:16.000 | And then an A.
00:49:23.000 | So capital B doesn't.
00:49:44.000 | Yeah, that makes sense. So it's saying, and remember this is sorting in reverse, right?
00:49:50.000 | So because, so it's saying this is the order in which I want the letters to appear. So let's try to come up with maybe a better example.
00:50:00.000 | Like A, B, C, D, E, F, G.
00:50:12.000 | Okay.
00:50:23.000 | So I want to sort C first, and then G, and then F, and then everything else.
00:50:38.000 | So to sort that, then I say
00:50:45.000 | A bracket B.
00:50:53.000 | For some reason I'm offended by the bracket thing, I kind of like the squad thing.
00:50:59.000 | Okay, fair enough.
00:51:03.000 | So now it has, and this is in reverse order, so it's got the C's last, then the G's, then the F's, and then everything else is not being moved at all.
00:51:18.000 | Just for my own practice.
00:51:27.000 | I want B sorted into, or sorted, B is the sort order for A.
00:51:56.000 | So I could just say A, is that right? A is sort by B.
00:52:04.000 | You have to enclose it.
00:52:07.000 | Oh, which one needs to be enclosed again?
00:52:12.000 | Closures.
00:52:14.000 | No, back in '47 we don't enclose.
00:52:20.000 | No, we do enclose it. Okay, that's right. Yes, yes, yes.
00:52:25.000 | Squad expects an enclosed argument on the left, or squad into, if you want to call it that, would be on the right.
00:52:42.000 | Okay, cool.
00:52:45.000 | Oh, the other way we could just do it is beyond the right.
00:52:50.000 | Let's just do it here. Sorry. Squad. Okay, enclose, which is a sure, which is this one.
00:53:03.000 | Should it be the other way?
00:53:06.000 | Should it?
00:53:11.000 | I think so.
00:53:13.000 | Okay.
00:53:17.000 | So A is the thing we're indexing, indexed by enclosed B.
00:53:29.000 | Cool.
00:53:31.000 | The examples they gave in the docs, or was it the APL Wiki? And the APL Wiki are good because they're using things like Quad A, and that contains the alphabet.
00:53:50.000 | So that's saying do it in alphabetical order.
00:53:54.000 | And we haven't done this yet, but I know it means mirror, flip, rotate, whatever. So this is A backwards, so this would be reverse alphabetical order.
00:54:23.000 | Okay.
00:54:46.000 | Cool.
00:55:12.000 | Let's do this, shall we?
00:55:41.000 | Okay.
00:56:08.000 | I think broadly speaking, we call these rotates and transpose.
00:56:37.000 | Okay.
00:56:45.000 | This is called.
00:56:48.000 | It's percent.
00:56:50.000 | Oh, that's nice. It's next to it on the keyboard.
00:56:55.000 | I think all three of those are going to be the percent, the up here in the name percent. So five, six, seven.
00:57:03.000 | Andy. All right.
00:57:16.880 | Thank you.
00:57:45.880 | And where do we define our matrix? Up here somewhere. There we are.
00:58:07.880 | All right.
00:58:19.880 | Not much to talk about this one as far as I can see.
00:58:34.880 | Niotic.
00:58:39.880 | I see. Rotate.
00:58:42.880 | I'm going to do this.
00:59:10.880 | Okay. So this is just taking, so it might be easier if we do one at a time.
00:59:16.880 | So this will take the first element from the front and put it on the back.
00:59:20.880 | It's rotating them. It's like if you imagine that they're in a circle, it's rotating them around one.
00:59:26.880 | That's going to be doing my three.
00:59:29.880 | This is going in the opposite direction, taking stuff off the end and putting it at the front.
00:59:42.880 | This is doing it for each row.
00:59:55.880 | And this is doing it by a different amount for each row.
01:00:03.880 | I really wish they used broadcasting in APL with the same rules as NumPy.
01:00:11.880 | It makes stuff like this so much more consistent.
01:00:16.880 | It did broadcast in 82, no? What's that? In 82, it did broadcast. In 82, did you say?
01:00:24.880 | Or 82, line 82 in your script.
01:00:28.880 | Oh, it broadcasts, it always broadcasts scalars to rank anything arrays.
01:00:37.880 | But it doesn't in any very general way broadcast vectors to matrices, for example.
01:00:46.880 | So, for example, I don't believe you can do this.
01:00:51.880 | No, sorry.
01:00:53.880 | It's like it's in NumPy, there's a set of rules, and they're super flexible in terms of how they work.
01:01:02.880 | Any combination of ranks, and you can permute transpose or add unit axes to get it to do exactly what you want.
01:01:11.880 | Or else in APL, some of them kind of behave like this case, it's kind of doing it, broadcasting each element of the left to each row on the right.
01:01:25.880 | The left-hand side has to be three numbers.
01:01:29.880 | Yeah, and it just depends. It works for this particular glyph, but not all glyphs. The fact that that doesn't work for plus, I don't understand why they do it that way.
01:01:41.880 | So the NumPy broadcasting rules, like there's only three of them, and they're just fantastically flexible.
01:01:58.880 | And they also work in PyTorch, and they also work in TensorFlow, etc. Probably Jans, Kupy.
01:02:08.880 | All right.
01:02:12.880 | So that one.
01:02:21.880 | Maybe I'm missing something. I don't know.
01:02:25.880 | I think it's, I think in both cases, I think it's, it's not really doing broadcasting. I think it's just applying the function, or it seems like it's applying the function.
01:02:45.880 | Right, it's a special case of a function with a left-hand side, which is rank one, and a right-hand side that's ranked two. You know, it behaves like broadcasting in this special case, exactly.
01:03:02.880 | Rory is an object, and so you're probably like...
01:03:05.880 | I don't know.
01:03:09.880 | Okay, so then there's the one that goes the other direction.
01:03:18.880 | Which I guess is Terat. Nope, probably Ampersand. Yep.
01:03:24.880 | Presumably this is, yeah, just the first version. It's like the bar version. Okay, circle bar.
01:03:33.880 | Mind you, it was 1am for Rory, he might want to sleep.
01:03:38.880 | Circle bar.
01:03:42.880 | He doesn't like broadcasting and new access and stuff.
01:03:46.880 | Likes rank, but doesn't know enough about it to make the reasonable argument.
01:04:01.880 | My argument basically is that should work.
01:04:06.880 | The fact that it doesn't seems like a missed opportunity.
01:04:11.880 | Or alternatively, that should work.
01:04:14.880 | Like, you know, it should pick an axis by default and just do it.
01:04:19.880 | You can do it with rank, but it just seems like totally unnecessary to force you to have a rank when you don't need one.
01:04:28.880 | Okay, magnetic, circle bar.
01:04:36.880 | By the way, Rory, you don't need new axis. You can just use none, which makes it a bit less wordy.
01:04:49.880 | Reverse, first.
01:04:52.880 | So it's only going to make a difference in the matrix case.
01:05:21.880 | The thing is, I mean, NumPy and stuff, they don't have anything like insert or reduce or whatever you want to call slope and stuff.
01:05:36.880 | So like there's a huge missed opportunity there, which is reductions in NumPy and not very flexible.
01:05:45.880 | And there isn't a rank operator. So like the things where you want that, it's missing.
01:05:50.880 | I want something with both. I want broadcasting, insert/reduce and rank operator.
01:05:58.880 | I think I want APL with this kind of like the rank operator should not be required in situations where NumPy's broadcasting rules could work.
01:06:08.880 | I think that's what I want.
01:06:16.880 | NumPy has reduced, though. I mean, I just googled it. I didn't know what...
01:06:20.880 | Well, it has a reduce. Right. But it's not nearly as rich as reduced with a rank operator, you know.
01:06:42.880 | So, yeah, it does apply to UFunk along an axis.
01:06:54.880 | So that's, I mean, that's cool.
01:07:02.880 | One thing I'm not sure about is the performance stuff around reduce, how well that works.
01:07:13.880 | But I think it's a lot less rich than, you know, scan and all that stuff with rank.
01:07:30.880 | Okay.
01:07:49.880 | That's the same.
01:07:57.880 | That's what we'd expect. Okay.
01:08:10.880 | So I think the next one presumably is going to be transposed based on how it's spelt.
01:08:18.880 | Or how it looks. This is carat.
01:08:34.880 | Called circle backslash.
01:08:40.880 | And it is just transposed.
01:08:46.880 | And there was a whole arraycast episode about transpose, which Rory's getting excited about in the chat because there's dyadic transpose.
01:08:56.880 | Although I'm not sure we're going to get quite as excited about it as Connor did because we're all very used to it because it's pronounced permute in PyTorch and we're very familiar with it.
01:09:05.880 | So, yeah, so transpose is, yeah, so as I say, there was two episodes on leading axis theory and transpose if I remember correctly.
01:09:22.880 | For people in deep learning, they're extremely familiar because we do it all the time, you know, because in if you've got a video of 3D reconstructions of
01:09:39.880 | multichannel color data, you've got time, depth, x, y, channel, put them in batches, you've got a rank 6 tensor.
01:09:55.880 | And so when you want to, you know, take the mean across, well, you can take the mean across an axis with an axis argument but like if you want to do things flexibly, you use dot permute in PyTorch to put the thing in the order you want.
01:10:08.880 | So that you can then do everything on the trailing axis, whereas on APL everything happens on the leading axis, which is fine.
01:10:17.880 | We're always asking about doing repeated axes. Okay, let's come to that. Alright, so transpose. Now the thing I can't quite remember from the chat is what happens when you transpose higher rank.
01:10:28.880 | So let's do that as well.
01:10:31.880 | And I know all the different array languages do things a little bit differently.
01:10:40.880 | So let's start with our matrix.
01:10:50.880 | I don't know. Okay.
01:11:00.880 | Stop pressing the wrong button.
01:11:03.880 | Transpose.
01:11:08.880 | Okay.
01:11:11.880 | I really wish we had Python magic in APL kernel or APL magic in a Python kernel because then we could very easily mix and match, compare, you know, NumPy and whatever.
01:11:26.880 | I think something I've requested and Rodrigo I believe is working on.
01:11:35.880 | So that'd be cool.
01:11:37.880 | That's pineapple, no?
01:11:39.880 | No, it doesn't have magics. Pineapple lets you evaluate a string. It would be actually pretty straightforward to turn it into a magic or probably only like three or four lines of code, I'm guessing.
01:11:49.880 | Okay.
01:11:50.880 | But he did say they're trying to.
01:11:53.880 | I don't think pineapples had a lot of love by the sounds of it. That's the way he kind of described it. So I think they're trying to make it a bit better.
01:12:00.880 | Okay, this is two by three by four.
01:12:16.880 | Actually, this is one we probably want to print out.
01:12:27.880 | Okay, so it's
01:12:33.880 | Okay, yeah, it's reversed all the axes. So transpose on a higher rank just reverses the axes.
01:12:41.880 | Turns it from two, three, four to four, three, two.
01:12:44.880 | So that's what monadic transpose does. And I believe dyadic transpose just lets you say what order you want to put them in, which I think is I think it's the same as .permute in PyTorch.
01:12:58.880 | Except that you can repeat the axes, which I don't think we can do in PyTorch as far as I know.
01:13:08.880 | I guess we could try it.
01:13:10.880 | Never tried it, honestly.
01:13:23.880 | Okay, so let's
01:13:30.880 | warnings.
01:13:33.880 | Okay, so we'll create an array.
01:13:42.880 | 1, 2, 3,
01:13:47.880 | 4, 5, 6,
01:13:50.880 | 7, 8, 9.
01:13:56.880 | Okay, m.permute
01:14:02.880 | 1, 2, oops.
01:14:09.880 | Oh, not an APL anymore.
01:14:14.880 | Okay, that's transpose.
01:14:19.880 | No, okay, so you can't repeat. So there's a difference.
01:14:24.880 | Although of course in, I guess to do that in PyTorch, we would use insum. So insum can do exactly that.
01:14:37.880 | But I do, you know, this is another thing of like, okay, why haven't they made it more general? I guess nobody thought of it. So it'd be, I like it when things are more general rather than most general.
01:14:49.880 | So that's something we should definitely look at.
01:14:52.880 | Okay.
01:15:04.880 | Okay, oh my goodness. All right, Barry's giving us things to try to confuse us. Let's do that. That'll be fun.
01:15:19.880 | So we can do
01:15:24.880 | so to flip axes one and two
01:15:30.880 | two, one, three transpose
01:15:34.880 | cube. I don't think we have to print it out. Let's just print out its shape.
01:15:39.880 | Okay, so that's, that's what you'd expect.
01:15:44.880 | And then for the matrix
01:15:54.880 | we can obviously just do a normal transpose.
01:16:13.880 | Now, what if we do two, two?
01:16:20.880 | Okay.
01:16:23.880 | So what is that really doing when you've got a repeating
01:16:27.880 | the ith element of x? It's a new position for the ith axis.
01:16:44.880 | Okay, so we need to probably look at some of these details a bit more to learn why that
01:16:48.880 | spell one one diagonal.
01:16:59.880 | Okay, so
01:17:01.880 | Rory wants us to try this one, which is
01:17:08.880 | treble copying.
01:17:18.880 | Okay, so
01:17:24.880 | one, five, nine
01:17:29.880 | fourteen, eighteen, twenty-two. Oh, that's interesting.
01:17:37.880 | Okay.
01:17:44.880 | Question if we don't understand what it does. Do we need it.
01:17:53.880 | I don't think you can know if you need something until you know what it does.
01:17:57.880 | No, I know what the opposite is true also.
01:18:06.880 | Oh, I see.
01:18:09.880 | Right, so in the nth position, you can, the maximum you can have is n minus one.
01:18:18.880 | That's why we got the rank error.
01:18:26.880 | Does the documentation say what it does?
01:18:29.880 | Oh, no, it's not quite that.
01:18:32.880 | Oh, no, it's more confusing than I thought. Alright, so the details of how
01:18:38.880 | rank duplicated elements of the left hand side is something we can definitely experiment with a bit more.
01:18:47.880 | Sounds interesting.
01:18:53.880 | So probably worth printing this one out because it's a bit confusing.
01:19:13.880 | Yeah, I can kind of see how this is this explains what it does when there's duplicates.
01:19:23.880 | Yeah, yeah, I mean, the manual tells you all that.
01:19:26.880 | I'm not going to look at it in too much detail right now.
01:19:30.880 | Sounds fun. Yeah. Okay, great.
01:19:43.880 | Question mark, I feel like we could deal with in the first notebook actually, it's pretty fundamental.
01:19:54.880 | Because it's random number generation.
01:19:59.880 | I can say basic math operators are to say basic math functions because they're not operators.
01:20:28.880 | Okay.
01:20:49.880 | Well, I hadn't noticed the non integer version of the role before.
01:20:58.880 | Okay.
01:21:27.880 | Okay, so it generates a random number between one and each and on the right hand side.
01:21:37.880 | And it looks like zero might be a special case that creates gives you a float between zero and one.
01:21:46.880 | Yeah.
01:21:47.880 | Yeah.
01:21:51.880 | Okay, okay.
01:21:54.880 | Different random number generators are available.
01:21:57.880 | Why is that not a link. Come on, people.
01:22:03.880 | Okay.
01:22:15.880 | Okay.
01:22:19.880 | This is called deal.
01:22:25.880 | I know these because I've done them with Claire already.
01:22:38.880 | So that's going to select 13 elements, 13 numbers between one and 52 without replacement.
01:23:08.880 | Cool. X random selections from iota y.
01:23:15.880 | So something which was fun to play with I won't do it now is if you create a character vector containing ace 234 etc j q k, and then another one containing the Unicode characters for each suit, you can then actually deal cards using this.
01:23:39.880 | That's the name.
01:23:45.880 | All right.
01:23:47.880 | It seems like a good time to stop.
01:23:51.880 | Thanks for joining the bonus session.
01:23:55.880 | Yeah, thank you.
01:23:57.880 | We're getting close to the end of the bus.
01:23:59.880 | Thank heavens.
01:24:01.880 | I'm fun but I'm so after the glyphs what are you planning to do in terms of a PR.
01:24:11.880 | I'll probably pause it for a while.
01:24:14.880 | Because I want to do some nb dev live coding.
01:24:21.880 | Yeah, if people can create some like, I think, like the best thing would be if folks could add pros to those notebooks after we're done, and maybe create some good Enki decks and then, like I feel like we're, you know, have a community of people that understand
01:24:36.880 | all the APO glyphs and could start to build the next level of documentation on top of that or tutorials I should say on top of that.
01:24:45.880 | I'm also interested in the q amp.
01:24:54.880 | Something interesting about big q n is that I think it's got a, you know, smaller meter implementation, like, because, because APL is a full programming language.
01:25:17.880 | It's, it's, it's big, you know, it's got all this, like, which is fine but it's got all this.net stuff and control flows stuff and, you know, it's kind of like a standard library of things in a web server and blah blah blah.
01:25:31.880 | So big q n is just, you know, just the notation and the implementation of that notation, which is the bit I'm more interested in.
01:25:43.880 | More like a regular expression.
01:25:46.880 | Might be more suitable for this. Anyway, certainly be interesting to explore to like, see how that feels.
01:25:58.880 | See the differences.
01:26:01.880 | So, anyway, I don't have any particular plans I'd ever make plans, honestly.
01:26:07.880 | Thanks again for doing all this. Thanks all. Bye.
01:26:14.880 | [BLANK_AUDIO]