 As I make this video, I respectfully acknowledge that I am standing on the unceded traditional territory of the Comox First Nation. And now let's take a look at Trace. Trace is a verb that a lot of people may not know about in J. It's really useful. Now, it's sort of sitting in the background, but you have to load it first. So this is the first step in order to start playing with Trace. You go into your session and you load and then put quotes around it, Trace. So what's Trace going to do? Well, let's take a look at an example. So I'm going to put quotes around squaring a list. So now Trace is going to tell me that as it went through that sentence that I gave it, the first rule that it hit was the monadic verb rule. It says, I've got a monadic verb. So it applied the monadic verb rule. It said the power, the squaring verb is the verb I'm dealing with. And this is the list that it's applying to and that's the result. So it's really simple, but it's going to go through the parsing that J does and do it in the order that J does it. And that's not always the order that you expect. But let's just take a look and see what some of the simple parts of speech look like. So first of all, obviously we've done a monadic verb. Let's do a diadic verb. So we're adding one, two, three to one, two, three. And it says, okay, the first rule that I hit that applies is the diadic rule. And so the diadic rule says, on one side I've got one noun. On the other side I've got another noun. In the middle I've got a verb. I apply the diadic rule and I get two, four, six is my result. So Trace is actually showing you how J parses something. Let's do adverbs next. So I'll do an adverb this way. And here's what an adverb would look like. Slightly different than what we were doing with verbs. So the first rule it sees that it can apply is the adverb rule. So it skips over this whole argument here and says, oh, first rule I can reapply is an adverb rule. And that adverb rule says, here's my verb, here's my adverb, and here's the new verb that's created. So now I've got this new verb. Then it looks at this new verb in relation to the argument and it says, oh, okay, with this new verb and this argument I'm dealing with a monadic verb. And it applies that, ends up with the result of six. You can do the same thing with the conjunctions, of course. So let's try a conjunction here. I'm going to have ad squaring. So when I do this, of course the first rule it sees is going to skip over this part. It's going to go into right into here and it's going to say, ah, that ad tells me there's a conjunction. There's the ad. On either side there's having and there's squaring and I'm going to make this verb. I look at that verb and I say in the next step the first thing that applies will be the monadic verb and this whole verb will be applied monadically. So it's going to square each of these things and then it's going to halve them to get this result. You can even do assignment. So you're not held back in this. You can do something like this assignment. It's going to do the same thing it did before except after some of the conjunction, made its verb, applied the monadic verb. The next rule it sees after that is the is rule. And that is rule says now I'm going to take what's on the right side of the assignment and I'm going to apply it to the left side of the assignment. So it's kind of like a dyadic thing but you're using an assignment or a copula in the center. So and then the result of course will be this. Now where it can get kind of useful. Let's take a look at something here. I am going to change that to times. I will change this to squared. I won't even bother with this anymore. I'm not going to do assignment. It just takes up extra space. And so in my mind, I'll tell you what I had in mind when I wrote this. I'll tell you right now it's wrong. But what I had in my mind was I'm going to insert multiplication between each of these to get six and then I'm going to square it. But as it goes through this process, the parser in J is going to do what it's supposed to do. Not necessarily what I want it to do but what it's supposed to do. What it does first is it goes along this string and the first time it has something that matches is going to be this conjunction. And it's going to take the conjunction between squaring and multiplying. It's going to make that into a verb. So it's put those together right off the bat. Next step it looks it says oh there's an adverb. I'm going to take this verb with this insert adverb. Now I'm going to make this into a verb. So now we're sitting with what turns out to be a monadic verb because when it comes to look at this, it's only got one argument so it's got to be a monadic verb, it's going to take this whole thing and it's going to insert it between each of these numbers. So if you insert this verb in between two and three, you get two times three squared which is 36. Okay 36 is there but I've got to do it again between one and the result of 36. So I've got one times 36 squared 1296. So it's giving me what it's supposed to do but maybe not what I was asking for. How do I get what I was asking for? This is where parentheses come into play and you see that you need parentheses when you're dealing with conjunctions with other operators because they tend to be greedy to the left. They always try and grab to the left so you have to separate them from the left. When you're dealing with other verbs and things, you're kind of working from right to left. But in the case of operators like conjunctions and adverbs, you've got to separate them because they always want to zing to their left. So when I do this, now I've got starting with trace but the first step it takes is not a conjunction like it did above here. This is what it did first. It did the whole thing as a conjunction. It's not going to do it that way this time. Now it's going to first look at the multiplication and the insert. It's going to make this into a verb. Then it's going to say, oh, by the way, use parentheses. Yeah, I know I did that on purpose. And now the next step is it's going to do a conjunction between at and the squaring and the insert of the multiplied. So now it's going to create this verb, which when it gets down here it's going to say it's only got one argument so it's got to be a monadic verb. And now I've got 1 times 2 times 3 in there. And then I'm applying squared to get 36. So trace is pretty useful. The one thing that is kind of a pain with it is you're trying to insert inside a string. So if you're dealing with string characters, so I'll just do something really simple like this, I have to double quote around a string because I've got a string within a string. When I hit trace on this, it's again a really simple thing, of course. It's doing from to to from ABC. So it's a dyadic verb. It's got to is one argument and ABC is the other argument. You can see here it's got single quotes because that's actually what I'm putting in. That's why I had to double quote it here because I'm inside quotes. But when it actually gets to working with it, it's single quotes. And it's selecting from ABC to give me C. And that's my result. So trace is a really interesting, useful verb to have in your arsenal. All you need just to have access to it is load trace. But if you don't use load trace, you type in trace and you'll get undeclared or undefined or something like that because it doesn't know what trace is. You have to load it first. So hopefully that helps you. And that's a little bit of J.