Good afternoon. My name is Claudio. I'm really excited to be here at RubyConf. As I was saying, this is actually a talk about Ruby, but the Ruby programming language. It's a language that we all love to write. We love to read. It's a language that is a little old, but it's still evolving. As a matter of fact, there is a new release every year, and there are new methods added every year. This is just an overview of some of the methods that I'm going to touch during this talk, and some of them have been in Ruby for many years, and others are new. They were just added in 2.4 released last December. The format that I chose for this talk is a refactoring journey, and I invite you all to come to this journey with me. What we're going to do is we're going to take a problem. It's actually a real problem that I had in my previous job, and then try to find the solution in Ruby with a first pass, and then iterate through the problem using some of these methods to make the code better. Whether you are a beginner or an expert Ruby developer, I hope you will all learn something from this talk. Now that the doors have magically closed, we can get it started. Let me give you some context here, because this is the example, the problem that we're going to use to look at those methods. It has to do with YouTube URLs. In my previous job, I had to deal with YouTube URLs a lot. If you have ever watched a video on YouTube, you have probably seen a URL of the first type that is a YouTube video. The second URL is also a YouTube video. It's just a shorter format. The third and the fourth one are URLs for YouTube channels, and then the last one is for a YouTube playlist. What we have here is different URLs, but really different strings that mean different things. What we're going to try to write is a method that is called parse, and it accepts a string as an input, and it's going to tell us what type of YouTube resource we are looking at. In the first case, that is a YouTube video. Ideally, this method parse would tell us it's a type video, and that's the idea of the video. In the second case, that is a YouTube channel, so that's what we expect. We expect type channel in the name of the channel. The third one, it's not a YouTube URL, so it's simply type unknown. Now, because we are Rubyist, we're not going to be happy with just writing code that is correct and complete. We want something more. We're also going to try to write code that is clear, meaning readable, and compact to follow the philosophy of do not repeat yourself. This is the problem that I'm going to talk about in the next 30 minutes, and before I start looking into that, I'm just going to stop here for a second and give you all a chance to think about this. If this was like a job interview or something like that, and this was the problem, what methods would you use if you had all the methods of the Ruby standard library available to try to solve this? Okay, so let's start, and I'm going to give it a first pass. So what I can observe here is that those URLs, they start in different ways. The first one starts with YouTube.com slash watch, and I can imagine that is a video. The second one just starts with YouTube.com slash, and then I can imagine that's a channel. The first, the last one doesn't even have YouTube, so maybe unknown. So my first attempt is going to be to use the method startWith from string, and this is straight from the documentation, startWith returns true if the string starts with one of the prefixes given. So you can say, hello, startWith hell, true. You can also ask hello, startWith haven, hell. It's also true because one of the prefixes is a match. Hello, startWith haven, paradise, that's false. So using this method, we can try to find the type of a URL, and this is how our first pass would look like. So how does this rank for what we're trying to achieve? Well, it's not perfect. I would say it's clear, meaning it's pre-readable. It's pretty English if text starts with and so on. It's not compact because we have some repetition there. The method startWith appears twice. It's not complete. We're only trying to match the type. We're not returning the ID or the name, and even worse, it's not correct. And the reason why I say that is because if your URL is simply youtube.com slash, that is not a channel. That is actually YouTube's home page. And the reason is that YouTube has some strict rules about how the URLs are formed. And this is basically the rule. When you have a video on YouTube, every video has a unique ID. And this ID is always 11 characters. And it's not any 11 characters. They are all letters, digits, underscore, or hyphen. So I don't know if you knew this. Maybe this is something you can take away from this talk. When you have a channel name, also, it has to have at least one of these characters. So as you can see, it's not as easy as just saying startWith. We need something more powerful. We need to deal with regular expressions. So for the next iteration, we can use this method string match question mark. This is actually a new method. It was just added to Ruby 2.4. And it lets you compare string with a regular expression, and it's going to tell you whether it's a match or not. In the first case, the string Ruby is a match for r dot dot dot, which means r and any three characters. That's true. But if you just try r dot dot, that's false because it's missing one character. And if you try p dot dot dot, it's also false because the first letter is an r, it's not a p. So using this method, we can now rewrite our code to look like this. If it's a match for a certain regular expression, then it's a video. Otherwise, it's a channel. Otherwise, it's unknown. Now, let me explain what this regular expression means. For instance, the first one is youtube.com slash watch question mark v equal that has to match exactly. And then there is this thing in square brackets. What the backslash w means is match any letter, any digit, and the underscore. So it's all there in that backslash w. The only other thing that we want to match is the hyphen, so we just add it there. And then the number 11 is a quantifier in curly brackets, and it means we need to match exactly 11 occurrences of those characters. So that's exactly what we want. That's what a youtube video URL looks like. In the second case, we still have the same square brackets, and we have the plus sign. That means it has to match at least one occurrences. So a channel name needs at least one character. And so with this in mind, we now have a solution that is correct. We're now actually matching videos, channels, or unknown. And I would say it's still pretty clear. It still reads pretty English. It's not complete. We're only returning the type and not the name. And it's not compact. As you can see, we have some repetition. Text match, text match. So let's give it another try, and let's try to remove this duplication. To do that, we're going to use the triple equal operator. This is what the Ruby documentation says. Following a regular expression literal with a triple equal operator allows you to compare against a string. And even more important, it's used in case statements. What that means is that if you want, you can explicitly use the triple equal, try to compare r dot dot dot to Ruby. That's true. But you don't have to, because if you use a case statement, then internally, Ruby is going to use that operator. So if you say case Ruby, when p dot dot dot, Ruby is actually using that operator. And if it's true, then it's going to return starts with p. Otherwise, it's going to return starts with r. So it's kind of the same as before, but it allows us to remove some duplication because we don't have to repeat match. So in short, we can take the code we had before and slightly change it to use a case when statement. Case text, when it matches the first regular expression is a video and so on. So the code is still correct. It's still pretty clear and now it's compact. We're not repeating any method. But it's not complete. We're only returning the type. And if you remember, we wanted to return two things. For instance, when we match a video, we want to return the type and the ID. When we match a channel, we want the type and the name. So we are maybe halfway through it, but we're still missing one part. In short, what we want is when we have a match, the thing that we're matching, we want to return it. So if we look back at the code that we had, those 11 characters that we're matching, we want to capture them and then we want to give them a name, ID, and then return that in the result. Same thing with the channel. When we're matching a channel name, we want to return it. So how do we do that? How can we capture and name these groups? We can use another feature of the Ruby standard library called regular expression captures. What it means is when you write regular expressions in Ruby, you can actually group a part of the expression in parentheses and you can give it a name. And if you do that, then when you have a match, you can ask just for that match in return. This is an example from the Ruby docs again. Let's say you want to match the string $3.67 and you have a regular expression that is the dollar sign, then this group in parentheses that we call dollars, it's any number of digits, then you have that and then another group called cents. So once you have a match, then you can just say, give me from the last match just the dollar amount. And that is what that dollar till the symbol means is a special variable that holds the value of the last match. So you can just say, give me the dollar amount of the last match, you're going to get three, give me the cent amount of the last match, you're going to get 67. So with this in mind, we can now write our code in a slightly different way. It starts to look a little complicated, but it's not very different from before. We have the same regular expressions, but now we're capturing the thing that we're matching. So in the first case, we're capturing and we're calling that ID. And then if it's a match, we're going to take that and return it in the resulting hash as ID. In the second case, we're matching what is the channel name and then we're returning it. And so finally, we have a solution that is correct and it's also complete. So if we were now writing Ruby, we could just stop here and say, well, this just works. I don't care if it's readable, if it's complex, let's just go to some other problem, but we're writing Ruby, so we want to make things a little better. Specifically in this case, it's still not compact because we're still repeating something here. This ID, this name that we gave, we actually see three times and same with name below. So is there a way not to have this repetition? Well, I'm glad you asked because there is. It's another method that was just added to Ruby 2.4 and it's called named captures. The concept is very similar to what we just saw with captures. It's just a more compact and elegant way. Basically, when you're capturing multiple groups, you can just call this single method named captures and you get back all of them. You don't have to individually specify I want the dollar amount or I want the cent amount. This is the same example as before, so if we just call named captures on the last match, we're just going to get a hash back that says dollars three cents 67. So let's see how we can use this in the code that we have. Let me break it down. For instance, let's say that we're trying to match the URL youtube.com slash conflicts. That is the name of a channel. When it's a match, this named capture is just going to return a hash. In this case, name conflicts. All we need is just then to add the other part that we want, the fact that the type is a channel, and we have back what we were looking for. So in this case, name conflicts type channel. So the code is becoming a little more dense, but it's doing exactly what we want. And this is how the code looks like. When we're capturing a video URL, then we get the ID back in named captures, and we just attach type video, and we have the result that we want. When we're capturing the channel name, it's the same thing. Now, is this any better than before? Well, I don't know. Maybe we now are just hitting our head against the wall because it feels like we're not really getting anywhere. We still have code that it's not really clear. It's not compact. Now we're repeating something else. So it feels like we're iterating, but we're really not getting there. And this is a feeling that you all might experience when you're trying to make your code better. You think you're following some path that's going to lead somewhere, and then it doesn't. So normally when this happens, I take a coffee break or a lunch break, or I just go home and sleep, and then in the morning I'm just like, wow, now I know what I have to do. I have to use something completely different. So we don't have time to go home and sleep. So I'm just going to skip that part. But it does work like that. When you are looking at a problem too much, you don't see exactly why things are happening. And in this case, this repetition is happening because what we've had so far is either if, else if, else if, or case, when, when, and it's almost in the nature of these structures to have some repetition because you are listing all the options. As I said at the beginning, there are even more options of YouTube URLs. So if we had to do that, we would probably end up with some repetition. So is there a way in Ruby not to do that, and instead to have Ruby itself do that for you? Yes. There is. So this is really like the biggest jump that we are going to make now. We're going to jump and talk about enumerables. So enumerables is a class and really the structure that sets Ruby apart from many other languages. What are enumerables? Arrays, hashes, ranges, you know, things that you can iterate through. And the enumerable class has this find method that is very powerful. Once again from the docs, if you use find, it passes each entry to the block and it's returning the first for which the block is not false. So basically you have a list of objects and Ruby is going to go through all of them one by one and try to see if there's one of them that matches your condition. And as soon as it finds one, it's going to stop and return that one. The first example, if you have all the integers from 18 to 99 and you say find a number that is divisible by 17, internally Ruby is going to say if 18 divisible by 17, then return it. Else if 19, else if 20 and so on. But you don't have to write that. And as soon as it reaches 34, it's just going to return that for you. Another characteristic of this method is that if it does not find a match, for instance, if you're trying to find a number between 18 and 29 that's divisible by 17, by default, it's just going to return nil. But you can actually overwrite that. You can tell Ruby what to return if there is no match. You do that with that extra argument if none. So in the last case, I'm just saying if you don't find a match, just return the value zero. So it's really powerful because then you don't have to write if, else if you just use the power of numerables. So now jumping back to our problem, this is really like the biggest change that we're going to see. We're not dealing with cases anymore. What we are doing here is we are recognizing that we have a list of patterns. Those are the same patterns that we talked about before. The first one is the regular expression that matches a video ID. And that is going to be of type video. The second one for a channel is the type channel. So we're just basically giving a name to these things called patterns. And then what we're telling Ruby to do is just go through these patterns one by one. Try to see if the text that you get is a match for any of this regular expression. As soon as you find a match, just return what we wanted from before. Type video ID 123. So once again, it's pretty powerful because now we only have eight lines of code and we don't have any method that's been repeated. The only portion that's missing is that gray line. How can we return something, you know, what we want in that case? Basically, how can we tell this find a method that as soon as it finds a match, it has to return something specific what we wanted to return and not just the first match. To do that, we have to use the break statement. So what break does is, you know, exactly that if you have a loop and you can use break to break out of the loop and to return a specific result. In this example, in the first case, we're not using break. We're just saying stop as soon as you find the number that's divisible by 17. Find is simply going to return the number itself, 34. But if you want to return something else, for instance, a string found it, then we can just use break. And then we say break with that value when you find it. And so that's what we're going to do here and we're going to use break. So now this code is becoming very dense, but it's really getting to the core of it. It's saying go through all the patterns. So patterns find, try to see if there is a match for an irregular expression. If there is, stop there. Take what you captured in the match, for instance, ID and the ID of the video, and then just add the type that you matched. So if we're matching a video URL, we're going to get type of video and the ID. If we're matching a channel URL, we're going to get type channel and the name. If we're not matching anything, if you remember, we want to just return type unknown, and we can just put it there. We can just use this extra argument of find to just say this is what you can return if there is no match. And so this is getting close to really being very compact. You can actually make it even more compact if you inline the if condition. And this is as compact as it can get, probably. It's still correct. It's still complete. But now we're dealing with clear, like is it readable? That is probably the most subjective of those characteristics. Some people might find it readable. Some people like compact code, very dense. Other people like to be a little more verbose. So I don't have an answer for that. What we can try to do is we can see if we can do a last iteration to make it a little more explicit. So for our last iteration, I'm just going to take a step back and remind ourselves where we wanted to get. We wanted to have a method that is able to parse all these different formats of URLs. Now in the code that we have so far, we're actually only dealing with two of those formats, the video ID and the channel name. If we had to put all of them in this code, it would actually look more like this. And now it starts becoming even not readable because I guess it's a very long hash. And, you know, this pattern structure that we identified, now it doesn't really have a specific meaning. It's including many patterns. We have patterns for videos, patterns for channels, patterns for playlists. So just for ourselves, just to make the code more readable, what is important and what's also one of the hardest things to do is to name things. Since we have identified that some of these are video patterns and some of them are channel patterns and playlist patterns, it actually makes sense to separate them in different constants. Because if we give them a name, then we kind of don't even have to read the regular expression. We just say, oh, this is the list of video patterns. If ever YouTube has a new way, we can just add it there, but we don't have to actually read. Once it's there, it's there. We have channel patterns and we have playlist patterns. So it's very declarative. It's very readable. The only step that it's missing is we want an object that it's basically going to go through all of them. First it's going to try all the video patterns one by one and stop as soon as you find a match. Then it's going to go through all the channel patterns and so on. And so this is the very last method from the Ruby Standard Library that I'm going to introduce today and that is enumerator.new. What this method does is it creates a new enumerator object which can be used as an enumerable. So it's an object that you can tell Ruby to iterate through. And this is what we're going to want here. We want an object that basically first goes through all the video patterns, then through all the channel patterns and playlist patterns. And this is how you write that code. You just use enumerator.new and then once again it's very declarative. Inside the block, you say, well, first for each video pattern, add it to the pattern and then if it's a match, the type is video, then do the same for all the playlist patterns and for all the channel patterns. And so here we are now with this code that it might be maybe too dense. As I said before, some people might prefer another format and I'm happy to discuss this with all of you after this talk. But I think it has some advantages. The first one is that really all the first lines of code, they're just declaration. We're just saying these are video patterns, channel patterns, playlist patterns and patterns. So that part really is going to stay as it is. And the bulk of your code is just the last three lines of code. That's where we're doing the real iteration. So if the first lines seem a little scary, those are just things that you're going to write once and they're going to stay like that unless YouTube adds more formats and you're just going to add them there. And your real logic is just those three lines at the bottom. So in my opinion, this code is correct and it's complete for sure. It's compact for sure, maybe too much. And in my opinion, it's clear because of this, because it's really defining things as they come. And instead, if you have like an if, else if, or a case statement, you can't escape from it. Like as you're reading, you have to read all the conditions diagonal in a way. And so this is basically what I'm going to stop. I'm just going to add one very last thing. Those patterns that I typed at the top, they just say YouTube.com. But really, YouTube URLs can also be www.youtube.com. They can be HTTP, YouTube.com, HTTPS, YouTube.com. You don't want to add all of that, you know, those variants at the top. You can just tell a match to match an interpolated regular expression that has optional captures is basically matching every regular expression and also this variance. Whether there is W or not, it's still going to be a match. So I know that was a lot after lunch. But I really wrote this talk to just give you an overview of the power of some methods that are inside the Ruby standard library. And as somebody said, yes, in another talk, Ruby is very powerful and you can do amazing things with it, both in a good way and in a bad way. You can just play around. There are no rules. These are some of the concepts that I introduced. And I think this was a great journey to have because if you guys have different opinions and if you have seen something that gave you some other ideas, just feel free to talk to me. That's all I have. And once again, the slides are available. And I'm up for questions if you have any. Thank you. The question is, would I consider extracting those into separate classes? Yes, I would. I tried to keep it compact in this talk. But yeah, that's a good idea. For instance, those video, channel, playlist patterns, they can definitely be their own classes. So you can play around with it. I really can't see anything.  Thank you.


So, now we are simply going to go to the tutorials just keep solving ourselves and again you know this problem maybe we will take a little bit longer to solve also because lot of geometries are usually involved in 3D equilibrium. So, we can just go through the steps as such when you know we are solving it. So, if you can just go through these problems quickly we will just work on the tutorial now. So, anyway I will just explain these are two bearings here and these are T shaped welded bar. So, this total body is continuous there is no breaking here. So, only supported by two bearings at A and B and we want to find out the reaction that is coming from the wall sorry about this. So, there is D is that wall ok. So, ultimately you know what is the concept here is that taking the moment about the A B axis, but before we do that you know we need to kind of convince people ok how the bearing reactions are acting why we are able to do the you know why we are able to take the moment about the A B axis that is the whole issue ok. Now, you take the moment about A B axis, but can we really try to figure out that I do have a you know moment that I do have a force from the wall that is along the x axis. So, when you take the moment about the A B axis of that force which component actually contributes to that you know moment about A B you have a D x that is acting along the x axis right. So, we need to take the component of that D x which is perpendicular to the A B that is all. So, we need to find the distance here and that distance is you know typically if we create a point here hip let us say this point is F here and we need to find this F c which is the perpendicular distance from C to the wall ok. So, that distance needs to be found out. So, that distance once we know that this problem can be solved very easily that is the hint. So, one have already you know one of you has found the this thing the distance D that I was talking about that is actually perpendicular distance from C to the wall ok. So, that distance is very important once we know that distance and also we need an angle somewhere because we have to now kind of you know because we have this D x here that D x has to be rotated such that it is again perpendicular to the line A B ok. So, once we do that right then we can simply take the moment very easily. So, 375 Newton is the answer just quickly show you the information that we need. So, the basically we are looking at this distance that distance is stated as F c ok. So, there is F and this F c should be equals to 300 that is the first thing. Second thing is that see ultimately we can see there is a theta here that theta needs to be calculated because we want to take the component of the D x right which is again parallel to the C f that is ok. So, ultimately you know we have this small D is understood that D here right that D is actually the length F c small D ok. So, this is the equation that is important is the only equation that is required to solve this problem ok. E multiplied by D over 2 because you have this D is actually F c and then we have D x sin theta. So, that sin theta component will be right parallel to the F c ok and then you multiply that by 300 to get the moment about A B. So, the final answer will be 375 Newton as one of you have answered. So, the moment about an axis here again is very important you know moment replace an important role that we have seen. So, let us move on to the next problem as such it will actually take you know all the problems will take minimum half an hour. So, let us just move on to the next problem. It is a very popular problem I would say it is given in all the you know courses that I have seen so far and it is nice to look at also because you know we play with this thing in day to day life. So, we have the tripod here and just remember some of the things that we have to keep in mind is the camera is uniformly weight of the camera is uniformly distributed ok. So, the camera weight is uniformly distributed which should pass through its mass center own mass center and also the line of action of the weight of the tripod that is said to be passing through D the D point is here. So, the vertical components of the reactions at A B and C we have to find when theta is equals to 0. Now, what is important is this camera is being moved is being rotated about the y axis ok and we want to find out that when it is going to actually tip off alright that tip off condition is very important. So, this problem is given just to you know understand that what is the tip off condition when the tip off will happen ok. So, first part is as such you know very straight forward. So, we make the theta equals to 0. So, what happens? So, all the if you look at the weight that is coming from the tripod and also the weight that is coming from the camera they should all pass through a maximum value of theta again you know these are all conversion problem. So, the maximum value of theta we keep on moving the camera right rotating the camera what is the maximum value of theta if the tripod is not to tip over. So, we look to we need to look at you know this problem from the top view. So, we just have to make sure that we draw the free body diagram in this plane all the forces again will be acting perpendicular to this plane. All the forces that we see they are acting perpendicular to the plane that is relevant to this problem ok. So, we draw the free body diagram only on that plane and these are all parallel force systems again we are looking at all parallel force system and those forces are going to be perpendicular to this. So, reactions are vertical we are going to get the vertical reactions from A, B and C that is all ok. Now, draw that free body diagram on this plane with all the forces those are actually parallel force system we have. As such it is a you know it does have some computation as if specially for this part we are going to do in a lot of computation, but this part is very straight forward that answer at least we should be able to do it. The idea is here that we are rotating the camera ok the camera is rotated about the y axis. So, as you keep doing that what happens the mass center of the camera is going to be shifted also right and what happens what is the basic concept can we imagine that there is a line A C. If you draw this line A C and think of moment about A C to topple over what will happen is that we have one force that is coming from the tri force. The other force we also coming from the mass center right. So, now these two will create a equivalent system as if and when that force that equivalent force is actually going you know on the other direction of the line A C it is going to topple. So, ultimate condition for the toppling will be what is the condition for the tip over. The reaction at the B will be equals to 0 that is the condition we have to use. So, at the verge of tipping R B equals to 0. So, the question was it is not to tip over that means R B or B Y let us say. So, B Y should be greater than as long as B Y is greater. So, I will quickly you know show you the free body diagram I think just a hint to this problem. I think ultimately how do you draw the free body diagram? See this is the part A free body diagram ok. So, this is the you know point D through which the weight of the tripod the weight of the tripod is 0.44 pound right and the camera right. So, camera weight that is going to be acting at a distance of 1.4 inch because if we look at the mass center of the camera right. So, that is going to be 1.4 inch away from the D. Why? Because see ultimately it is 4.8 divided by 2. So, 2.4 negative 1 right. So, that should be the distance of the mass center from D 2.4 negative 1 ok. So, that is how we draw the free body diagram which is very very important and the rest of the procedure will easily follow now. So, now how do I find out A in one go? The A Y can be found out by taking the moment about the line B C and someone already said the answer is going to be 0.65 pound ok. Similarly, what we can do? We can try to find out either B or C by taking the moment about x axis right. So, B and C that equation of what is the relationship between B and C? So, that they are equal in this case ok. I was in this case it is fine, but ultimately we have also we have to also make use of the vertical equilibrium condition. So, A Y plus B Y plus C Y equals to the force. So, from there we can actually solve for the B Y and C Y. So, in the first case yes they are equal ok B Y and C Y. So, in the second problem what is basically happening? I will again show the free body diagram. So, procedure is going to be same. So, this is the free body diagram ultimately this theta needs to be found. So, I have rotated the camera. So, mass center has been moved by this theta. So, remember this 1.4 inch is still there right. So, only concern is this theta which we have to find and the condition is that not to tip over B Y should always be greater than 0. So, ultimately find the expression for B Y in terms of theta that is what we have to do and once we say that expression is established. So, B Y just greater than equals to 0 we will solve for the theta ok. There is also an important part here as I said that one can also think of this problem like this if we join AC ok there is a line. See ultimately what is happening if we study this problem very carefully these two makes an equivalent system that is located somewhere between let us say D and this point as we keep moving the as we keep rotating the camera right ok. And ultimately what will happen that equivalent force as soon as it actually cuts the AC line as soon as it cuts the AC line then immediately B Y will be equals to 0 because if we take the moment of everything about the line AC ok. So, that procedure can also be adopted that also we can. I mean it is a bit lengthy problem and definitely it is not going to be an exam problem I would not say, but it is going to be more or less a homework problem. But condition of keeping is something that we have to you know impart to the student very carefully. So, the answer if we want to find out we have to go through the process ultimately setting up expression for B Y that we can do now. How do we set up the expression for B Y? One is that we take the moment about the x axis that is already done. So, you get a relationship between C Y and B Y now ok. Other thing that we should do take the moment about an axis that is parallel to Z, but passing through A. So, let us say axis A Z. If we take the moment about this then again we can have a equation that is relating B Y and C Y. So, from these two equation we solve for B Y in terms of theta and then say B Y is greater than 0. So, these are again so far we had basically you know single rigid body action. Now, we just study also the multi body actions ok. So, all the connections are here ball and socket joint. There are three members everything is a ball and socket joint. And the question is posed very very carefully. Use only three equilibrium conditions to find x component of reactions at C B and A. So, first part let us just try to do that and then others can follow. We can try to find out what are the number you know how many unknowns are there, how many equations we have. Just a hint because we have already started to the equilibrium. Now, in 3 D is there in two force member in this body in this frame? Is there any two force member? B E is a two force member why because they are connected by pins it is almost pins because ball and socket joint now it forms a pin. So, to hold the equilibrium the net reaction has to be equal and opposite ok. So, therefore, at the very far beginning we have to understand that B Y equals to 0 and E Y equals to 0 because it is a two force it becomes a two force member. You have only axial load in B E ok and due to that we should not have any B Y and E Y. Now, we can start solving I mean now the issue will be very very simple. So, that is the only concept that is required here because no lateral load is applied in B E it is simply ball and socket joint at the two ends right and therefore, it will only carry the axial load in this problem. Now, this is a typical you know final exam problem actually. So, C X is 2 that is correct A X is the answer the minus plus is a issue definitely how we have chosen, but magnitude is not correct A X should be 0.6 and B X is 2.6. So, how do you do that? So, can you take a moment about B Y C X is 2 right and C X can be found moment about Y axis passing through point. So, it has to be you know you can find it very easily from this freeway diagram D Y take moment about D Y see one in one go you can find it from that freeway only. So, in one go if you really want to find out what is C X I should take a moment about D Y of this particular bar ok I take a moment about Y axis of this bar that will solve for the C X very easily. So, C X is at the top take the moment about D Y then we come to that member A B C in the member A B C if we take a moment about D Y that will solve for A X and if we do the sum of force along X direction equals to 0 that will solve for B X ok. So, thing will follow like that. So, that is why the question was spoke was that only use three equilibrium conditions to solve for A X B X and C X, but see here I do not know what the main intension was to find out that there is a two force member and that really you know solve the problem very quickly. The rest of the you know things we can just keep taking the various moment and force conditions that we have from various free bodies, but these are all the answers is that ok.


Yeah, can you put a link on the Blackboard submission site to the submission site? Yes. Sure. Then maybe now and I'll go develop it all together. Any other questions? All right, presenter views, good to go. I'll note to what's coming next. So it'll be fun. It's like a hot point. All right. Cool. All right. So we talked about at the end of the programming language, we talked about what are all the components of a compiler and a program analysis system or a program interpretation system, right? So what was the flexible analysis section? What does that actually do? So I think of them like boxes, right? What are the inputs and what are the outputs? In terms of characters and the tokens. Yeah, characters play. More specific than bytes. Yes, that's what I want you to think about, right? It's turning bytes into a series of tokens. So why do we want that? Why is that useful? Because I can tell you that. I'll stay up here. It makes it more abstract. Abstraction. Yeah, exactly, right? It's abstraction. That's one of the default computer science answers, right? We like abstraction. So if you think of something like, oh yeah, because of abstraction. That's a big yes. But yes, it's true because we don't want to deal with the raw bytes. We want to deal with things at a higher level. So cart of flexible analysis is defining the syntax of the language. So what does it mean to be a valid program written in that language? And so why is this important? So why is it important that a programming language must have a clearly defined syntax? Is it important because I put it on the slide? No, because otherwise it's like English. There are just no rules. Yeah, well, there are some rules to English, maybe. Kind of, but a lot of them can be broken in very weird ways, right? Or I may talk to you in a way that's not exactly proper English, but you'll still understand exactly what I mean, right? Unfortunately, we can't rely on the compiler. We can't rely on a program to just infer what we meant.  It looks very similar to this other variable. You must have made that same variable and not a new variable, right? That would actually be kind of crazy to work with a programming language like that because you have to deal with all those things and worry about you making a mistake, right? So it needs to be clearly specified syntax. And the other also, the language needs to have syntax A so we can write compilers for it, right? So we can compile that program and interpret that program. But D, so U as a programmer can actually write a program in that language, right? And without clearly defined syntax, you won't know what's allowed or what's not allowed. You'll just have to learn to program by trial and error. You're just going to type garbage and see what happens and see if it's valid or not. Did some of you do that? Kind of do that. That's fine. So it's too quick, huh? People who write programs and people who write compilers that compile those programs. We need each of those things. So the input as we talked about is a series of bytes. So bytes are coming into our lexer. And so the key question we're going to be setting here is how do we get from just a string of characters to program execution, right?  We want to deal with things like instead of the characters I, followed by the character if, then if token, right? That's something more abstract. It's not the raw character. It's something a little bit more abstract. And this is what a program can understand and it can be done. So the output here, the goal, this is where we're going, is a series of tokens. So when you think lexical analysis, input bytes, output tokens. Bang, that's it. So anything to do with lexing is going to be generating tokens. So how do we know what the valid syntax is for English? So we talked about it a little bit, right? What do we have in English that tells us when things are right or not right? Grammar, what about the grammar? Just the way it's formatted using the alphabet. The way it's formatted using the alphabet? Yeah, what's lower than grammar? So grammar kind of, to me, defines what's a valid sentence or less. So it's a serious English syntax, but it's natural language syntax, but it's not as formal as. Right, but thinking about it at a high level, so we have to grammar which defines kind of how sentences look. What else do we have there? We have a 26-character alphabet. Yes, we have an alphabet, right? You can't just draw whatever you want and say, is this English or not? You can't make up your own letters if that would make this insane, right? Although maybe, I guess, now we're doing that with emojis, but that's the whole issue I don't want to get into. But yeah, so at the basic level, we need to say, okay, what are the characters? What's the broad things? What are we going to use to communicate? So in English, we have the alphabet, plus numbers, and maybe actually some other symbols. We actually have other things. What are some other things that aren't in the alphabet and aren't 0 or 9? Punctuation, what kind of punctuation? Period, x-point, ellipses. Let's somebody else go. Periods, ellipses, estimation points, question marks. What was that? Semicolons, dashes, like long dashes. Actually, there's three different kinds of dashes if you've never looked better before. It blew my mind the first time I learned that. All kinds of stuff, right? And this all encompasses the alphabet. So when you see something, you can say, yes, that is English. But it's not English because it has an n-y in it, and I'm trying to make English language. Unless you're writing something that's like English Spanish thing, whatever, but then you have other things, right? So we have all these characters that compose the alphabet, and we have a higher abstraction from that, right? So when you read this sentence, like think about this little meta, right? When you're reading this sentence in the slide, are you reading it character by character? Are you doing H-O-W-E-V-E-R, comma lines, I forgot that's called, comma, right? And then you go, aha, the word however. And then you go, W-E is we. So how do you know these differences between words? Spaces. Spaces, right? So that can be even considered another character in our language is a space.  But you know that they're abstract words. And of course, we can break down words into different types, right? We can have some words or nouns, some words or verbs, some words or adjectives, some words or other things that I've forgotten from my English class that I'm not going to try going to, right? But we have this higher abstraction to think about English, right? And we know words are valid because that was defined in a dictionary, right? Or we know some words are valid because we know the other person will kind of know what we mean, even if we use it a little bit weird. And words, we've categorized words, there's different types of words. And so sentences, right? So we group sentences, I know when a sentence ends and another one begins. Punctuation. Punctuation, yeah, a token, right? A period that says, hey, this is one finished sentence, I'm starting another sentence. And those can be grouped up into paragraphs. How do we know, how do we separate paragraphs? New lines and or indents, depending on the formatting, actually can be kind of difficult. I guess, wow. These are good things to think about when we send emails to people like professors if you just send a huge block of text as opposed to several paragraphs of text that are easy to digest. That's always good. Cool. So we have this structure in English, right? And so in a programming language with syntax, we have the same thing, right? We have an alphabet, we have the set of possible bytes that make sense in our language. Right? So maybe not every byte is valid in every C program. Right? Can you use a smiley face emoji in C? I seriously hope not. Hopefully nobody finds out. If you find something right now, let us know. That would be kind of cool. Actually, there aren't emojis in UTF-A. There are, but I don't think C uses UTF-A. Yeah, C is still UTF-A. Yeah. But you can do it in Python or other languages. I had a professor who did everything in Scala, and that was kind of cool because he was doing math stuff, and so you can have like unicode characters, so you can have like the actual aero character and like union operators and all that stuff. It was like horrible to write, but it looked so great when you're done because it matched up exactly what the math looked like. Right? But this is a decision, and this is the other thing I want us to think about. Right? So we're studying syntax. We're understanding how to do this, but I want you to understand that the people that wrote the C programming language, right, they made decisions about what's going to be in the alphabet of that language. They made decisions about what does it need to be a word, in that sense. What does it need to be a sentence? Right? And those decisions affect you, but ultimately they're just engineering trade-off decisions. Right? So it seems you have this actually, you know, a little bit, I don't know if it's slightly bigger than English, but there are a lot of characters in here, right? That we have to use, and maybe you've gotten used to figuring out where they all are in your keyboard on that row on top. And so, just like we saw in English, the abstraction of words, right? We don't want to deal with characters. We want to deal with words. We want to deal with tokens. And so is where the idea of token comes in. For instance, in C, or a C-like language, what does two equal signs next to each other mean? What does that mean? What does that mean? It's a quality test. It's a quality token, right? It's not two equal signs. It means something more. It's a specific token, right? And maybe somebody has made the error that I've made in a while statement instead of using two equal signs to compare things. You accidentally only use one equal sign, and then you're assigning value instead of testing equality. So one character difference means huge semantic difference for your program. It does something completely wrong, and you're pulling out your hair because it runs and you don't understand what's going on, right? Anybody need to adjust me? The only person that's done that. Cool. Let's start again in the class, or at the end of the semester. See how that goes. Okay. The left angle bracket and the equal sign? What's token is that? Less than or equal. Yeah, less than or equal, right? Semantically to us, it means one thing, even though it's two separate characters. While the character's W-H-I-L-E. Yeah, while token. It's a reserved keyword. Can you have a variable called Y-O-N-C or C plus plus? No. No. That's kind of, can be annoying sometimes. Well, maybe not wild, but maybe there's other things, right? But this is because those five characters next to each other, W-H-I-L-E, are special. They mean something special, right? They're an abstraction. They're a specific token themselves. Cool. If, just the same thing, and if token, right? And what we need to do and really what we're studying here in lexical analysis is how do we precisely specify these tokens? And so how are we going to do this is using patterns. So how many people have taken the 355? How many people are currently taking? Cool. Wow. All right, look around. You should form a support group or something. But, so there'll be a little bit of overlap here if we're covering the same concepts. But here we go in much more detail over there. So the idea is, so we have our alphabet. What's inside the alphabet? Characters. Characters. Yeah, individual bytes characters. Right? But we compose, if we concatenate characters together, we get what we're going to call a string. Right? Seems kind of silly why we need to define that, right? We've been talking about strings our entire programming career up in your education up until now. But we need to have precise definitions because we're going to talk about things like strings. So concatenating alphabet symbols together makes a string. And what we're going to do, so we're going to get a little bit more formal now because we're going to start actually defining what do we need by alphabet? What do we need by string? So we're going to use the sigma, capital sigma for the alphabet. And so we're going to say, so sigma is a finite set. So what do we need to be a finite set? It terminates at some point. And it's countable. Yes. Okay. Yes. So a finite set means that there's a countable, you can count, you know exactly how many elements there are in sigma. Right? So for a given programming language, if I say the language is just the characters a and b, then all programs written in that language can only have the characters a and b, which is very similar to what? Binary. Binary, right? Binary is ones and zeros. And the a's and b's are basically the same thing, right? So we're going to define a string. A string is a sequence of symbols from sigma. And we're going to have some special characters. So this is something we're going to use throughout the course. These things are important. So we're going to use epsilon is the empty string. That is epsilon, right? Yeah. Okay. None. Great. So epsilon is the empty string. Okay. So yes. So this means an empty sequence of symbols. Right? This means no symbols. So we have some rules that fall out from this. So if we concatenate epsilon with some string s, the result is just s. Right? Because epsilon is empty. So if epsilon concatenate with epsilon, what do I get? Epsilon. Epsilon. Cool. And this is just a different way of writing that. So we're going to use concatenation here just as the strings next to each other. So epsilon concatenated with s is the same as s concatenated with epsilon, which is the same as just s. So I'm going to try to do this. I can't guarantee that it happens all the time because as we've seen mistakes happen. So I'm going to try to stylize strings differently. So they'll either be inside double quotes or they'll be italic and dark blue. And this will distinguish between strings, which are sequences of symbols in our language from other things. Cool? Questions? So a string is simply just a sequence of characters. And each character is from a specific alphabet, a given alphabet, one alphabet. So then what do we mean by language? I'm going to define that a little bit more precisely. What was that? Just a set of strings. Just a random set of strings? Yeah, so a set of strings that are all valid programs in our language. We can think of like that. So this would be the set of every possible string that's valid in our language. So sigma is the set of all symbols in our alphabet. And sigma star is the set of all strings in sigma. So what does this mean when we use in the kind of mathematical notation when we use sigma star? It doesn't mean the set of all strings other than sigma. What was that? It can repeat. Yeah, it can repeat. So it's every possible combination of strings that can be made using all the characters from sigma. So for instance, let me flip over here. Hey, it's all working. Isn't that weird? At least for now. Okay, so if we have sigma as we said, if sigma is the symbol a and the symbol b, then sigma star will contain what? What about epsilon? Yeah. Yeah? By using none of those strings in here, we get epsilon? The singleton set of a, the singleton set of b, and ab. Yeah. Wait, you're talking about sets, though. It's sets, but we say we were concatenating, so it's strings. So a set of all strings. Yeah, so it's every possible order matters here, right? So we're not talking about sets, we're talking about strings. So yeah, we'll have a, a, a. We'll also have a, a, a, a. If I just sat here and kept doing this, am I going to stop? No. So what does that tell you about sigma star? It is not a set. It's not a finite set, right? Does an infinite set, it's never going to finish? But if I gave you a string and I said, is this string in sigma star, would you be able to answer that question? Yes. Yes. Right, so if I said a, c, a, is that in, is that an element of sigma star? No, it is not. So we're going to do this, sigma star contains all strings that can be created by combining the alphabet symbols into a string. So, sigma star defines every possible string that can ever be made. So if you think about, like, an infinite, like, a bunch of monkeys inferring a keyboard that only has the characters that are in sigma, every possible thing with those infinite number of monkeys can write all those strings that may be in sigma. Sigma star. So we're going to find a language. So a language is going to be a subset of sigma star. Right? So we're going to say from all possible, sigma star is all possible strings you could ever write in this language. We're going to, oh sorry, with this alphabet, L is going to be just those strings that are valid in programs, or that are valid according to this language. So, very sad, is sigma infinite? No. No, right? You already really defined a cache, a finite set. Sigma star? Yes. Yeah, what are you saying? Is L infinite? Yes. So let me argue yes or no. So we're going to guess it now. Is it infinite? Different number of ways you could write any programs. So yes? Maybe I want to take the no side? Yeah. I was just going to say epsilon star is the subset of epsilon star. That's the infinite set. So therefore it's infinite. Okay, so I'm going to take the other side. You're going to take the other side? Yeah, so I think it's finite. This is actually running into one of the problems with a finite set theory right now. I think it's finite. It needs to be finite. And it's infinitely finite. You can't really define it as finite. So if L is indefinitely large, we wouldn't be able to decide whether or not a particular string is in the language or not until we've compared it against all the strings that are in L, which would take in a long time. But we already said we can tell easily you can decide if a string is in sigma star and sigma star is infinite. Right? I think you said that. I don't know if we decided that. Okay, cool. So if we're taking your word for it, then what else? Easily. Cool. Yeah, I think the algorithm is pretty easy. You look at every character, any character in the string, if every character in the string is in sigma, then that string is going to be in sigma star. Because sigma star is all possible combinations of all characters in sigma. I think that's the only test, but that's just off the top of my head. But that's not defining things that. Right? But part of the thing is, all we have here is L is a subset of sigma star. Right? So who's defining L? We are. We are. The programming language designer is defining L. So really the answer is it depends, right? It depends on what L you're talking about and what rules there are for defining L. Could you write a programming language that has the caveat that let's say, I don't know, the maximum character size is 140 bytes? Yes. Yeah, you could write that language. Would L be finite or infinite in that case? Finite. Finite, because you can enumerate all, every possible combination of letters in your alphabet that are in L are going to be in there. Are most programming languages like this? No. No, right? You can always, and you can think of it this easily, right? You can always add a new line of code to your program. Right? It may not even affect things. You can just keep adding lines of code. Now, there may actually be practical limitations that I don't know what the limitations are from files of both size and input files that L accept. That would be kind of interesting. Something interesting to explore. And so really, there's no hard or fast answers here. Really, both ways are correct, but I want you to think about both ways, right? Because we are defining L, and that's why the answer is, well, my answer is independent, right? Cool. Okay. So the way we are going to precisely define the strings that are in L is through regular expressions. So regular expressions are going to help us precisely define exactly what we mean when we talk about, what strings are in a language L. So, have you ever used regular expressions before? In a job. Somebody is raising a hand, and I want to tell us what they use it for. Yeah, so like to validate or check that mid-user input is valid into the date? Yeah. What language? Ooh, BB, not that nice. Ooh, parsing through and trying to extract information from a lot of your text. What language? JavaScript. JavaScript? Have you got anything else in a different language? Ooh, validating email addresses in Rails. Keep that in mind. We're going to get to that. I'll show you why it's a bad idea later. Cool. Yeah, so the point of this is to talk about that we're not just learning esoteric regular expressions and regular languages and all this because we like to think about theory things, which we do because we're computer scientists, but these are actually things that people use every day in their jobs, right? Regular expressions come up very frequently. So this is one of those beautiful cases where theory needs practice in something that you use all the time. So this is an area where you spend time getting familiar with regular expressions because they're going to come up and they're going to come up a lot. Okay. So tokens, the tokens of the language are typically specified using regular expressions. So that's why we're studying them now in this class. They also have really interesting theoretical components, but for this class it's a much more practical manner. We need a way of precisely identifying what do we mean by a token. So some people that have used regular expressions, especially in a job setting, what were they good for? Why did you use them? Did your boss fold you? Yeah, so they're kind of easy to create rules or validations, so kind of deciding how things match, talking about the matching thing. What did you like it? Hello. Did you like using? I think you could let me that argument against a lot of program languages and frameworks. Yeah, it's a lazy way to get something that kind of appears to work, but it really doesn't. Yeah, so you have to learn, essentially a new language in addition to the language that you're already using. And you can move from like, perl regular expressions to JavaScript regular expressions to maybe vv.net regular expressions. They may all have slightly different impacts for what you're used to, so then things can change that way. What are some of the pros? So we talked about some of the cons. What are some of the good things? So it's actually like, as we'll see, we can describe an infinite, a super large, you know, an it, I actually said something to say super large, but we can describe an infinite set of strings using four or five characters. As long as people know how to interpret that regular expression, you can express very complicated things in a short amount of characters. Definitely. So, you know, they're compact. They're expressive. We'll kind of see just a little bit of where the bounds are on this expressiveness. They're precise, right? I can show you a regular expression, and as long as we're talking about the exact same regular expression language, you should be able to know exactly what strings match that and are in that language, and what strings are outside that language. Why these? I think, hopefully, some of your fellow students have convinced you that people actually do these things. And we're not going to be into it, but they're actually incredibly efficient. So, especially the ones we're going to talk about here, but it's easy, in some sense, in some sense, it's easy to generate an efficient program to match a regular expression. So this is often why it's used in programming and in real world projects. Cool. Okay. Now, so somebody posted on the email list about VM Inception. Now we're kind of in syntax Inception. So, I told you we need to talk about syntax, right? We're going to learn regular expressions so we can define the syntax of a language. But, regular expressions themselves are a language, so we need to define the syntax of regular expressions in order to talk about regular expressions to talk about syntax of languages, right? So we've found ourselves in a loop. Okay, so we're going to do it kind of formally. That's the way we get around this. So, we're going to say that a regular expression is either an empty string, so here we're using this as an empty string, epsilon. So empty string would be no regular expression. The empty string would be, so now, remember, it's okay, it's just like, n, alright. I'm going to do it. Okay. So, we need to find things that are regular expressions, right? So we need to find the syntax of a regular expression. So a regular expression is either going to be one of these things. It's either going to be the empty set, which we'll talk about some entity with that means. It's going to be epsilon. It is going to be, I'll cheat a little bit, okay, good. Make sure I do the syntax, right? Okay, cool. A, where A is an element of sigma, right? So this would be A is some symbol in our language, right? So all symbols in our language are valid regular expressions. Cool. We have r1 bar r2 where r1 and r2 are regular expressions. So what kind of definition is this? Recursive. That's recursive definition, right? Cool. Okay. So this means that bar is a special character essentially in our regular expression language, right? This means something. We'll talk about exactly what it means in a second. The other thing I guess I should note is especially in your academic career, people use syntax differently. So we're going to follow the syntax that I think is closely related to real programming languages. So, you know, if you see, it's slightly different. You're going to have to deal with learning the different things because this is why we're precisely defining exactly what it means. Okay, there we go. r1. r2 where r1 and r2 are regular expressions. So the dot character is a special character. Bracket r left, I should say left, left parenthesis, r right parenthesis where r is a regular expression.  And that's it. No more. Okay. So if I were to ask you a question like is this, oh yes. What is the difference between our first two options here, the empty set and the empty string? We'll talk about that eventually. So right now, I just wanted to find what regular expressions look like. So we have to define that first and then we have to define what do all of these things actually mean. Just like what we're going to do is talk about syntax and then we'll talk about semantics, right? So how does the program look versus what does the program mean? And so we have to do the same thing here. So I want to first build up. So that way, everyone knows when I show you something, this is a regular expression. So to do that, if I give you some string and I say, is this a regular expression, what do you need to know in order to make that determination? I give you the string. I say, is this a regular expression? Can you say yes or no? Yes. Yes? We need the alphabet. Why do we need the alphabet? To check case, yeah, if I number them, right? Case three, right? We need to know what is the alphabet. Exactly. So if I said here, the alphabet is the set containing A and the set containing B, then is this about a regular expression? No, it's a dot in between A and B. Oh, sorry. So yes. But if the language is only A, then it's not, because we have some B that's not in our language, and it's not one of our special regular expression symbols. So the only regular expression symbols, we have the bar, and I'll show you over here. Obviously it looks a little better here. So the dot can either be a period, or an actual dot in the middle.  It could be parentheses, or it could be the star. Questions on that? Yeah. Then we got problems. No, no, no. It would be fine. We would just have to, I mean, these are, so these, the bar, the dot, parentheses, the star, right? These are all arbitrary characters. Are those operators on regular expressions? And are they going to be defined at some point? Yes. We're going to find the semantics of these later. All right. We're talking about the syntax right now. So yeah. There are fours in this. Ah, yeah. We'll talk about that when we get a little bit to semantics. We're going to have some way of dealing with that, but it's not too important. It is important, because how, you know, how would you write a regular expression that matches the bar character? Like, vertical bar. You need some way of doing that, right? So we'll see a little bit later how we do that. But now I'm using things like, ask some questions. Okay. Let's do this. So let's use just the language. The alphabet is just a and b. And so we said, okay, the string a dot b is that a regular expression. Cool. What about a bar b? What about a bar bar b? So let's actually step back a little bit. So why did we know that this one is a regular expression? Which of these rules first applies? Rule four. Rule four. And then rule four only applies at what?  Yes. Yes. Both by rule three. Okay. So now let's look here and we say, okay, is a bar bar b? So which rule would apply there? So first four. Four. Four. So we have, but which is r1 and which one is r2? Yeah. A and b, md. A bar and then r2. Any other problem? Right? So this means that we have to be able to deconstruct this into an r1 and an r2 and a bar. So let's say, we can say r1 is, what, a bar and r2 is what, b? So is r2, is this a regular expression? Yes. Is this a regular expression? No. Yes. md, md, md. Yeah. Yeah. It's a bar. So it's b. md. Yeah. So if... Just a second. Guys, let's... With r1, r1 actually is a bar epsilon. Where's the epsilon? Well, it's empty, right? So... Is there an epsilon in there? No. It's 1. Right? Is there an epsilon in this original string? No. Technically. There is not. Right? We're just talking about just the characters that are in this string. Right? So you're saying a regular expression is either an empty set, which I kind of want to get rid of. It's not very important right now. Epsilon. Right? So let's think about it this way. Is this a valverie expression? Yes? By which rule? 2. 2. Great. Is this a valverie expression? No. Well, 4 first. And so what's r1 in this case? Epsilon. Epsilon. And what's r2? b. Exactly.  2. 2. And then b is also by 3. So this is valid. So let's go back to here. Is this a valid regular expression? Because there's nothing here. But isn't nothing the empty set? No. That's why I kind of want to get rid of it.  Think of it another way. Based on what we have here, is this a valid regular expression? Yes? No. So which one of these rules would apply? That's right. 5? Is there a dot in there? No. 3? 7? 7? Is there a star in there? There's a star in there? Did you say that the star is all of the set? No. You're putting your knowledge of what it is and your semantics onto it. We don't have any semantics. Exactly. Just based on looking at these rules, right? We would need a star character for rule 7 to appear. We need parentheses for rule 6 to apply. We need a dot character for rule 5 to apply. A star for rule 4 to apply. So which rule would apply? 3. Yeah. 3. So what's A in this case? It's AB. AB. Is AB in our language? What's in our language? B. A and B is AB in our language. Okay, so we came back. This is not in our language. So what about this? A bar B. Yes. Yes? Yes. What's that first? 4. 4. 4? And R2 would be epsilon and R1 would be everything over here? Yes. And then what's the rule of why? 7. 7 and then what? 6. 6. 7 and 6. 7 and 6. And then 4 and then 1, 3 and 3. Cool. Look at that. We didn't have to define syntax. We're already getting a feel for what A is not a regular expression. Cool. We're going to use regular expressions to define a language, right? We already talked about it. What is a language? Oh, question. Yeah. If I said, is this a regular expression? That's kind of what I wanted to do. Yeah. I don't think it comes up really in what we're going to do. For the rule of 7, for the rule of 7, you can ask that B and B. What was that? With the AB, you have to do the rule of 7, ask that. Because ask that has two elements and B. So the question, so AB, like this, the string AB, is this a regular expression? Yeah. By rule 7, there's no star in here, so the rule 7 can't apply. Right? You would need, so which rule applies here? That's rule 7. 7 applies here where R is A and star is due to rule 7.  Yes, by rule 3. So here, because there's literally no star character in our regular expression string, rule 7 doesn't apply here. Right? So all these rules can only apply when we see the characters. Yeah. That is more to do with semantics. So no, we're going to define the exact semantics of all these things later. It looks like next class. So I have a question. Yes. Is the null character the empty set or like semantically? It would be literally an empty set. So instead of saying like the string containing epsilon, this is the difference between the null character and the string containing epsilon. So it does have, I think it will have some semantic differences in the amount of time. Cool. All right. Let's go to the next class.


What's up guys, EvilDeer here. So today I'm going to speak to you about my first day in the army. Now I had spoken in previous vlogs about me being in the army for six years, but for those who are new to this channel, I was in the army for six years. Yes, I'm an Esperanist, yes I'm a pacifist, but I was also in the army for six years. Don't know how that works, but it just does. Wow, I just did one of the, uh-uh, type things. Anyway, so, my first day in the army, now, I was 17 at the time, and I remember that my parents drove probably like three hours to get to the Hobart Airport because we lived really far from Hobart. For those who don't know, Hobart's the capital of Tasmania, and Tasmania is just a massive freaking island hanging off the bottom of Australia.  There wasn't that many of us actually, there was only like two of us. Why did I say so many kitties? But there was two. Anyway, so I went to go on the plane. I was just about to hop on the plane because literally there's this building and you walk through it and then it's just open tarmac to the plane. You just like walk up onto the plane type of thing. There's no like massive terrorist detection or anything like that there. Anyway, so I'm just about to get on this plane, my dad just pulls me aside and he's like, son, today you can become a man. I'm like, yeah, I know that. I'm off to join the army, of course I'm going to become a man. And he's like, no, no, no son. Take one of these, look after it. And it was a condom he was holding his hand. I was like, we're having this conversation now? Haven't you neglected me all this time and now you're telling me this? And he's like, just, just hold on to it. You may have a use for it. And just to, just so you guys know, that thing literally rotted my wallet. I never found a use for it. God, that's so sad. But anyway, so I get up onto the plane and I'm on the plane. There's this one other little skinny dude right next to me. He's literally my skinniness at the time. We're like both 55 kilos. And he's like arms are like fricking, you know, two picks and he's like, come on, we're going to join the army. And now for all those out there thinking, well, hang on, don't, isn't the army like big, tough, meaty dudes type thing? Or surprisingly, no, like they have these physical tests where you've got to go for like this running, this push-ups and stuff. But if you can lift your own weight and run far enough, they don't care what size physically you are as long as you can handle yourself. So it was me and this one other little skinny dude on this plane. And the whole way he's like, yeah, I'm going to smash this down. It's going to be awesome. Oh, by the way, if you watched my previous V-LOGs, yeah, if you did, well, the guy that I randomly fly kicked in my previous V-LOG, this dude that was sitting right next to me. I don't know how this guy ended up next to me, but anyway. So yeah, we fly there. It takes like three hours. We land in Melbourne. They put us up in this like hotel for the night before the bus is meant to come pick us up with all the other people from Melbourne that day, you know, flying in from Perth and all the other locations. So we're staying in this hotel and we get this nice meal and I'm like, well, this is awesome type of thing. And the little dude that was with me, he's on the ground going, hey! 20, hey! 21, hey! 22, hey! 20 feet! 24, 25. Oh, man, I'm so strong type of thing, and at the time we're all like... That was pretty beefy. Anyway, so it was just me and him in the summer room. room we were like the tassie boys and there was just like this little fridge like the bar fridges that you have in there and there's like some chocolate in there and I love chocolate like I've been starved to chocolate up until this point because my parents never brought it that's probably a lie I hope mom and dad doesn't watch this but anyway so they had chocolate in the fridge and I grabbed some and I ate it but then I felt really guilty I'm like does the army pay for this fridge or do I have to pay for it so like literally just before we left I just left a couple of dollars laying on the bench because I wasn't sure what to do and I didn't want to ask anyone in case they'd go you can't eat the chocolate but anyway that was my biggest worry that day so we we parked it we went to bed and then the next day this bus rocks up just a standard bus nothing special doesn't have like I'll be the edge across the side of it but it's just this bus and there's all these other dudes you know all the civilian clothes like myself I wasn't exactly wearing this at the time oh god I didn't even button this up correctly sorry about that guys yeah that's terrible but anyway so we're waiting for the bus and our cops is great big warrant officer now for those of you who don't know military structure warrant officer is like the highest direct entry soldier that they can get to so it goes like corporal sergeant warrant officer and then there's like a few little ranks in between but that's pretty much it and then if you want to get above that you have to join the army as an officer and that means you got to go for uni and all that type of stuff but anyway so he's warrant officer that means he's been in for at least 15 to 20 plus years so this guy gets off the bus is big bloke like not mostly just big physically built and he's like hop on the bus little boys you know like he actually sounded like freaking Santa Claus he wasn't that bad of a bloke and everyone's like okay so we'll get on the bus we're taking our little bags and the whole way heading inland because the Army training base the initial one is located far inland and the whole way inland he's like well this is gonna be great you're gonna be trying new technology gonna get shoot guns you know you guys gonna be you're gonna be protecting the country it's gonna be all awesome he's like chatting to us individually as if we're like his best mates type of thing and we're like wow man we can really dig this this is awesome he's telling us all the type of stuff we want to hear and we approach the army barracks okay and it's got this big gate in front of it and you don't actually recognize it at the time but when you've been in there for six weeks as we had it stops being a gate turns into like the prison entrance where they shoot escapees but they don't actually shoot people but that's what you get mentally so you've gone up to this gate and there's this statue I can't remember what exactly what it was I just remember it stuck in my mind so but soon as we passed that statue the warrant officer just beforehand he's like yeah it's gonna be great and soon as we passed the statue just went like that his face just dropped and he just stopped talking everyone's like what's going on and he just stayed like this like literally just quiet for like the next minute until the bus pulled up obviously at like the main headquarters in this base and the door opens up and he turns at us all and he looks at us and goes get the fuck off the bus and we're all like yeah type of thing we're like ah and suddenly he's just demeanour just changed from this chatty nice old bloke to this I'm gonna rip your freaking legs off and feed it to the goat type of guy and we're all just getting off this bus and he's like yeah now you pieces of beep beep beep type of thing we're all like running off the bus and we're all like somehow getting all lined up and stuff and this guy's just walking in front of this like full on arms behind his back on you guys are the most disgusting pieces of beep I've ever seen type of thing and we're like whoa man this is like some hardcore type of stuff that you see in the movies the same real and some people are like like laughing almost because it doesn't seem so serious and then soon as they get seen that they're like yeah and then he walks away like why are you laughing at that and it's like you can literally see the speaker across his face he's like taking a type of thing like some really dodgy porno or something but anyway anyway so they line us all up and they just give us this equipment like they go this is your life from now on you have like five minutes a day to call your mother to cry about your life and it's like type of thing anyway so they take us off they divide us off into like these little platoons and at the time you just you just straight up get these like PT clothes you don't even get military clothes it's really like demeaning they give you this like I can't remember if it was a white or a gray but this white gray shirt like red pants or something like that or black pants I can't remember those nice spastic looking thing ever it's like one of those things you see in a really bad music video but anyway they give us these clothes and they take us off to this building and the whole time you just we're all just like kind of like attempting to march to this building as they're yelling at us saying left right left no one knows what that means we're just like and we get to this freaking building and they line us up in front of these rooms and there's like as I said in my previous videos it's the hallway and this is room room room room room and we're all lined up in front of these freaking rooms okay and I'm standing here like this like following what everyone else is doing everyone else has got their arms behind their backs so that's what I'm doing I don't know anything about the military so I'm just lying here standing up and the other guys standing opposite me and we're both like was this the best choice we made and the guy this is this corporal who comes down into the hall so what else has gone at this point he's obviously yelled enough for one day and he's probably off to have a smoke or something but anyway this corporal comes walking down the hallway and he stops at each soldier so he's like looks at you looks down looks up and goes and he's looking at these massive blokes they care like these Jimin built blokes that had come from other places in Australia he's like I've seen pieces of shit bigger than you my friend you won't last a week here and he just walks in the next place and he did they just stop at each plate and they just consult them and they come up to me and he looks at me and I'm 55 kilos at the time and I'm not military material and he's looking at me and he goes I'm disgusted to even think that I let you in here and he walks on and I'm just thinking I probably should have beat that bit out sorry I miss the first one god damn it anyway so they just yell at us and then literally I'll tell the rest of the military stories and in the next videos but that was my first day so it's just getting yelled at and we'd arrived in the morning at this point and we're just standing in the hallway getting yelled at and then getting handed equipment and stuff and then from there they took us off to like this big parade ground where they they just um gave like this speech or something about you know military I can't remember at this point everyone's just like should are we allowed to like breathe do we have to ask permission for this you know it's literally just just like that like everything is monitored and you're just if you've ever seen metal jacket like the movie it's like that but more evil like seriously it's more evil and you find out later on why they do that okay and I actually you know I'll tell you now why they do that the reason being is you don't notice when you come in straight away but the reason being is everyone comes in with their own set personality and what they want to do is instantly just break it down just smash your personality into personality into bits and take it apart and bring out the raw you and then they want to build on that and build a soldier because everyone comes in with their own little fears and their own like preconceptions about how good they are and stuff like that but then they just come along they just they literally just take it all off just bit by bit and then they say this is the new you and this is what we expected everyone's identical and they pretty much drum that into you by giving you a number like you still have your name and eventually your names like we serve names along your bit of clothing but you get a number everyone gets a number you ask any military guys been out for like 20 years they have a number and they know their number like literally it just friggin two weeks ago I had to call up about my military superannuation because I was trying to like roll into something else and I'd been out of military by this point for friggin six years or something and the first thing they said is what is your number you know basically and I'm like like it just instantly came out and you my number so yeah that is my story of the first day in the army so if you like this story you want to hear more crazy stories from me just share the shit out of this video tell me you know comment do something spastic I don't care just yeah tell me and I'll make more videos and I hope to see you in the next year and if not well then you are good enough to be here