 Okay, so first basics variables. So you assign variables as in basically any other programming language I know, except R with the equals sign, just an equals sign. If I execute that, well, it prints 42 because this line also evaluates into 42. But now my answer variable contains 42. Okay, so let's do another example. And if I'm typing too quickly, I mean, this is kind of a fast section. But just play along, you don't need to type exactly what I'm typing. So we can assign any value to my Pi. And let's check. So type of function is a built-in function. And it will tell me what the type of a thing is, it could be a function, it can be a variable. Okay. So this is a float 64 a 64 bit float. Let's also do a type of my answer. Okay, I can spell. So that's an integer, a 64 bit integer to be precise. Now, Julia is, well, it's a recent language. It's modern. It can use unicode characters. And there's a lot of unicode characters out there. For example, there is the cat. Did I do this right? Okay. So if you want to type a unicode character, you start with a slash and then type a name. Start with an a. Okay, I guess there's no alpha. No. But if you don't, yeah, you can type alpha like this, like with the latest syntax. So that's why it's not in the list. Like that. You press a tab key. So you start typing something, you press a tab key, and it prints a lot of stuff. You type a bit more and it basically narrows it down. And then you can choose from this list and press enter. Same for alpha. So at the end, you need to press tab to complete what you're writing. So yeah, there's a lot of unicode characters and the key post don't contain all of those characters. So in principle, it should be possible to type any currency or kanji or anything like that. But I'm not sure how to even start. I should add it here in the notes. So maybe take a note. We should be able to type Chinese and Japanese characters and Korean. I think Korean is unicode also. Okay. So now if I have a string, so this is just a standard thing. Standard string. This is a string. Okay. If you have a string right before you define something, that is documentation for that thing. So this is a string is now documentation for the variable A. A is a number. Okay. And why would we do that? Because then you can use the question mark to print. A is a number. Okay. So a more descriptive document string here would be useful. Usually you have literal strings as documentation. So that means having three quotations at the beginning at the end. And then you can also have later in there, I believe. You need to escape the dollar sign now. Like this? Yeah. It's not quite the same as the markdown string tax, but it works. And you're missing the backslash before alpha. Right. That was actually just me not writing later. Oh, but it's escaping. I need to escape the escape. Yeah. Okay. So now we have an alpha. Is there a way of having, there is a way of having literal strings, and I think it's in fact in the notes. So let's just not do that yet. When I write doc strings, generally I use the double like accent to the left to use method that should also work. No, I mean like normal literal string like that. Instead of the dollar sign. Yeah. I like this one. The other one. This one. Yeah. Double. Okay. And then I guess I need this one. Yeah. You're missing no one. Double quotation quote. Sorry. Yes. Okay. This is easier. Yeah. Yeah. But the double, like twice that symbol. Oh, you still need to escape this. Okay. Then literal strings would be better, I think. Did I do something wrong? Yeah, like the accent twice, left and right. And then the backslash before alpha. Yeah. Once or twice. No, just once. No, it should work. Oh, that's it. It works for the doc strings, but maybe it's because it's past the... Yeah. Maybe the... Oh, okay. Yeah. So I guess the notebook is different from... Yeah. That's not good. Good. Literal strings should always work the same. Do you remember they... Is it R for raw? Yeah, I think it should be. Yeah. Okay. So this is how I would write the doc string then, especially with any later in it. So with an R at the beginning. Okay. So there's an interlude. I mentioned special characters. Some special characters are already defined with a value like pi. That's kind of expected when you know that there are special... That pi, for example, is a character that Julie understands, then obviously pi is the numerical constant pi. Okay. Now, we did the type of for some variables. Let's say A equals one, B equals one. And... Okay, where am I typing? Type of A, A is an integer, 64-bit integer. There is... So this is to demonstrate that Julia is dynamically typed and loosely typed. So let's make this two. So that two... One divided by two is not an integer. So now it will produce a float. Right? So it automatically casts or changes the types of variables to match what you would expect. We could also do... Let's put this in the same cell. Oh, one divided by one is still a float. Okay. Good to know. Yeah. So the reason is that for type stability, because if it depended on the value, it wouldn't predict the type... Right. Okay. That's a very good point, but we'll come back to why that's a good point. Okay. Okay. So there's a bunch of number types. What you will get here when you just assign is always a basic type. So float 64 is a basic type. It's exactly 64-bits floating-point number. There's also 32-bits and 16-bit integers and floats. There's unsigned. So you could have a unsigned int, which is then always a positive integer. Oops. This declaration doesn't work on top level. Okay. Let's just look at them here. So there's unsigned integers, for example, and all sorts of types. Mostly when using Julia, I don't get into this specific stuff. But if it's useful for you to make the code faster, then you can. There's strings. Well, there's also abstract float, for example. So abstract float is just any kind of float, but it cannot be an integer, for example. Or you can do the same. You can force something to be an integer without specifying what kind of integer. So that's often useful. Then there's strings, characters, booleans, which is either true or false. And some composite types are complex, is already defined. There's arrays, which we'll come back to in mappings or dictionaries. And one more number type. So we can also do a sort of double divide, which will produce a fraction. And then it will figure out how to deal with fractions on its own. Like that. Okay. So that is sometimes super useful. This basic math section in the notes, which probably I'll just skip. Because it is what you expect it to be. And I have used probably all of those, except the power, which applies the multiplication multiple times, like you would expect. What you maybe wouldn't expect, or maybe would, is that you can use it for anything where the multiplication is defined. So if you define multiplication between two strings, for example, is defined, and therefore you can use the power to do that many times. So 10 to four is 10,000. And then there is the modulus operator. So let's take 101, modulo two. So that should produce one, right? Or modulo three, that is two. Okay. All right. And we come to our first exercise, and it is exactly 10. So let's take a break. I will try to have a break exactly every hour, or pretty much every hour, because it is a five hour day. So it will just listening and staring at the screen, even if you are typing along and doing some exercises, it will get tough. So when we get back in 10 minutes, then we'll get back to the exercises. Yeah. In the past, stop the screen share, because we needed something from this computer. But here we are again. So hopefully you are able to follow on the notes. And there's two exercises there, the standard introduction to a language exercises. So hello world, where you need to run the print function to print something. And as an advanced version, try to put it into a file, and then run that file, and then try to run some calculations in the notebook, or indeed at Julia command line itself. So how long do we need this? Maybe five minutes, and then I will do them myself, and you can type along. Surely 11 is halfway, pretty much halfway, because two of the people are teachers at 12. Okay, I will start demonstrating here, but feel free to mute me. And there are, there's the notebooks folder in intellectual materials. There is also a solutions folder. And in the solutions folder, you have our solutions to the exercises divided by each of the sections or each of the notebooks. How somebody is asking if you can do Python like string formatting, there is a way to do it, but it probably tomorrow. All right, so the easy version of the printing hello world is to run the print, and I will use print ln for a new line function, hello world, and that prints hello world. But I asked you to put it in a file. So I will also demonstrate something in the Jupiter interface, so you can open a terminal. I type into the terminal, I guess not. Okay, well, let's then use something simpler. Open a git bash terminal. So just to save some space, I will get rid of the prompt. Okay, and let's go to the introduction. Okay, so this is the main folder. And now I will create a file called hello.jl.jl is the standard extension for Julia programs. And now what is happening? I probably pasted something. Okay, but this is, yes, it is. Okay, good. So I will type in the same command print ln and string hello world and save that file. So now we have a file that just contains print ln hello world. And we can use Julia to run it. And it works as expected. Now a different window. Here we are. So for the second one, you can create a new cell in the notebook. Or you can, whenever you you're working on something, you can start a command line and start the Julia interpreter in that command line. And then just type commands in. So the first one was 100 plus 123. That's 223. I, to get five to the power of, there, okay, to the power of two, two times pi, that's not a two, two times pi. And in the Julia interpreter, writing the special characters works the same way. So you type slash pi and press tab. And that gives you a pi. Also, you can always just type a number and a variable and that implies multiplication. You can also also explicitly type in the multiplication. So let's do cos sign of two pi. Cos sign is built in and the cosine of two pi is one. And finally, E is not defined like we already saw. The euro coefficient is defined with this special character, which is not very visible here. Okay, that to the power of two is something like around seven, 7.4. Okay. And now, and next, there's a rational number thing. So if we just do three over five plus nine over 10, it will convert each into a floating point number and then do the addition. If we want to have an exact fraction, we use the the fractional division syntax. Okay, that's three over two. Okay. How many are done? How many are able to follow? 11. Yeah, it's still at 11. So 14 now. Yeah. I did the demonstration relatively quickly and probably in a different way than you did. So if you are struggling with anything, please put the red X or just ask the question on the HackMD. And I think I will move on with the... Okay, but let's move on. So I already mentioned that you can have a number in front of the variable. A variable name, it will imply multiplication. So that is actually the next thing in the notes. So this makes writing some expressions like polynomials look a lot nicer in Julia. But yeah, it's just a syntactic thing. It's not doing anything special in the background. But yeah, you can remember and then any expression, as long as that expression is not also a number. Okay, and then let's go on to arrays. So this is not quite the last basic type in Julia, but one of the three more complicated types in the basic Julia library, Julia base. So the way you define an array, let's start from beginning. The way you define an array is by using these square brackets in tags and just listing stuff inside. Oh, this is one way. Another way to define an array is very similar, but without the commas and using spaces instead. Now it will use the word vector for this one. A vector is a one-dimensional array. It uses the word matrix for the second one. It's a one times four matrix. So matrix is actually two-dimensional generally. So you define a matrix using this syntax where you have a space between each element in a row, but then between rows you have a semicolon. Okay, and now we have a two times four matrix. Let's define a one-dimensional array for demonstration. Okay, so it has six elements. And now the syntax for accessing an element in an array is basically standard. It's the same as in Python and it's also the same as in C. So hopefully it's familiar for most people. You can also get a view or a slice of a section, a view or a slice or a section of an array. One of those words should be hopefully familiar from another language. So this takes the first three elements from element one to element three. Let's take element four to six. So that's four, five and four. Okay. Or we can take the last element using the keyword end or let's say from three to the end like that. So that's useful. Okay. You don't need to define a new array for this. So you can also modify arrays. So yeah, arrays by default, arrays are mutable. You can modify them. You can change the elements and you can add new ones. So push, the push function will add an element to the end of an array. So you see tree was added at the end. There is also insert. And then you need to give the location where to put the new element. So we put one to put it in the beginning. So numbering elements in an array starts from one. So this is like in Fortran, but not like in Python or in C. Okay. Do you think we should comment about that bang in the name push and insert, like why it's push bang? I will get back to that in a moment. So yeah, there's one more. There's an append function which takes two arrays. The first one needs to be a variable because it's going to get modified. And the second one needs to be a list we can add at the end. So now it has added this at the end. Okay. So all of these three functions have an exclamation point at the end. And the exclamation point means that it's modifying an argument in one of the arguments for the function. This is purely a convention in Julia. So generally you should name any function that modifies its arguments with an exclamation point. But there's nothing enforcing this. This is not a part of the syntax. It's a convention. Okay. Just one small comment. The append bang works with the first is a constant array like a non-variable array because it also returns the modified array. So you can have a constant here. Yeah, but you can also have an array like one, two, for example. Yeah, for example, it still works. Okay. It modifies that but returns the object that has modified by convention. So it actually works. But this one doesn't exist. Which is... Yeah, that doesn't... Yeah. Okay. So it's taking this and modifying it but also returning it. Yes. So but if I want a handle on it, if I want to put in a variable, then I need to assign it to something. It will not be confused. If you break the syntax, Julia complains. If you break conventions, people complain. It's a good short way of answering the question. Yeah. We have one quick exercise on arrays. I'm wondering if this is the right place for it because we'll continue with arrays. Well, anyway, let's do it. So please remove the checkmark and add it back once you have done exercise four. So create an array and then using one of the functions above, add the number six at the end. Okay. Right. Okay. So you create an array using the square bracket syntax. And it should have the numbers one, two, three, four and five. So that's the first part. And then to add the number six at the end, you could use, for example, push. Another solution I didn't demonstrate, but that is probably a good thing to show is you can modify any part of the array. So you can take any slice or any place in the array and switch, change it to a different number that will only print the number that you have assigned. But the whole array has in fact changed. Okay. And you can use the end keyword to get the end of the array, put something there. Oh, oops, that didn't work. Okay. So that just changed the value of the last, it didn't add a new one. And probably this will fail as well. Yeah, out of bounds. Okay. I guess then you need to use push. But yeah, so one obvious, one way that I obviously should have included to modify an array is to use this syntax. All right. Now, we already did some n dimensional arrays. There are functions to quickly create those. So we did one and two dimensional arrays with the square bracket syntax. But when you get three or four, five dimensional ones, you probably want to use a function and some for loops to define them. So if you start with zeros, for example, you can create a three dimensional array by giving it three numbers, four dimensional array by giving four numbers and so on. That's a big one. Okay. And of course, ones. So zeros gives you zeros, ones gives you ones. And then there is also random, which will give you a random n dimensional array. Okay. Right. Now, arrays were one of the three base, more complicated, basic types, types that are in the Julia base, tuples are another one. So if you know Python, these are familiar. Tuple is like an array, except it cannot be modified. So this gives the compiler a lot of information actually, and something cannot be modified. It helps a lot. So you define them otherwise like an array, except you use the round brackets, standard brackets. So let's make a tuple of strings. So these animals, penguins, cats, and sugar gliders. All right. Yeah. So there seems to be a little confusion about why like one comma two comma three is a vector and one, two, three without commas is a matrix. So there are a few people puzzled by that. Like what is the difference in practice? Yeah. I think maybe one way to visualize it is that if you just type a vector and press enter in the cell, will it work? Yeah. Yeah, it says alias for array t1. Whereas if you type a matrix and press enter, it says alias for array t2. And if you now just forget about that t, forget it exists, if you focus on the one and two, what it's saying is that the vector is a one-dimensional array. So it's similar to a vital list. So you can like append things like to the end of it. Whereas a matrix is more like a mathematical matrix, like a two-dimensional array. And when you do one, two, three without commas, it's actually creating a two-dimensional matrix, despite it looks one-dimensional because, well, it's just a row, but it's actually two-dimensional. And so if you think like appending to a two-dimensional matrix doesn't really make that sense? Yeah, okay. So append is not that straight. Yeah, append you're pushing actually, I meant, but yeah. It doesn't work because they're not the same size. Right. Let's remove that. Yeah. So I mean, they basically both use array in the background. So they're not that different, but there's a lot more things defined for vectors or arrays with dimension one that are not defined for arrays of dimension two. And of course, you can create similarly, there is a type four array of, I have a type here, right? Dimension tree, let's say. So, and yeah, you can have any dimension for an array. Okay. So yeah, tuples are essentially like vectors, but you cannot change the tuple in any way. You have to create a new one. So you can take, let's say, the value at index two, you can see it, but you cannot modify it. So it will give you an error. I said, yeah, no method matching set index. There is no way to set the index or set it at the index. Okay, another thing, depending on what you do, this is either very important or something you will forget and never look back. It's a dictionary. Dictionary is a mapping of a key, which is usually a string. So in this case, the key is Jenny to a value, which in this case is a phone number because this is a phone book, my phone book, and nobody has numbers with this syntax or this type anymore. Well, yeah, I mean, if I add four, four there, then it is a real phone number. Okay. And of course you can add multiple. So clusters has a phone number that is 5552368. Okay, so that's a dictionary. And then you can access, by the way, this is a useful thing. So you can start typing a variable. And even you press tab, press tab. If it knows how to complete it, then it will. Okay. And you can get, like from the vector using the same syntax, you can get the value except that now you instead of giving a number, you need to give the key. Okay, so these are often very useful. You can also, so these are mutable, you can add stuff. And the way you add stuff is you take the index. This index doesn't exist, but you can still assign something to it. These examples are interesting. Now, if you try to add this again, it will work. But it will, of course, modify it because it already exists. So dictionaries are kind of a more general version of one-dimensional or any-dimensional arrays, in that arrays are just indexed with a number. The implementation is, of course, very different dictionaries are a bit slower. Okay. Now, you can do comparisons, like in any language. So we can say that one is smaller than, one is bigger than two. And that will evaluate in defaults. You can say one is equal to one. And that is equal, that evaluates it true. You can also compare strings. So this is the same as this. But if you change one of them, then they are not the same anymore. Okay. So there is a full list of comparisons in the notes, but these are basically the standard. One, yeah, one little difference here is, again, that you can use the unicode characters. So lg for larger, no, no, sorry, g for greater or equal, like that. So one is greater or equal than one. And the same for not equal. So if you try to say one is not equal to two, that evaluates it true. Okay. And in many languages, this cannot be chained. So for example, this might not make sense. But in Julia, it works as you would expect. So this is, this works like the mathematical expression. Okay. And then and an or work the same way as as you would expect also. So but the type or you need to use the two pipe characters. So like in C, but not like in Python, in Python, you can just type the word or. Okay. So false or true is true. And false and true is false. Okay. So two and characters is the and operator. Okay. So that's standard stuff. And then we can introduce a conditional. So let's just put variable, give it a value of six. Okay. So start with the if statement. Or actually, this is the only actual conditional that we'll use. So if variable is bigger than five, print something bigger than five. Okay. You can have an else if so. You need the condition there. If it's bigger than zero. So what happens here is it first checks if it's bigger than five is the first if the first condition is true. And if it's not, then it will check this one. If this is true, it will not check this one. Okay. This is supposed to be a string. So just print something. And let's just print Ellen again. And not just print. So bigger than zero, but smaller than five. You can have an else as well. So I'm kind of listing everything up, everything possible in an if block smaller than zero. Okay. And then you end the block with the end keyword, which is generally in Julia, you end blocks with the end keyword. Okay. Let's just run this. So the number is bigger than five, which is expected. If it's smaller than five, then this will evaluate false. So it will not do this one. Then it will try this one. This will be true. So it will do this one. Okay. Bigger than zero, but smaller than five. And finally, if the first one is false, the second one is false, you can have as many of these as we want. Then finally, it will do the else statement. You can also, you don't have to have an old statement. Then of course, you don't have to have any else. It's either. Okay. So that's the standard if statement. Four loops. So four loops look kind of like in Python in the sense that you need to have, you have four number in and then a list or some sort of iterable thing. So this is a range. A range of numbers from one to four. So the reason I'm using this example is that this will result in something that looks very much like a for loop in C and Fortran. It starts from one and ends at four. Okay. But you can also do for element in array. We have an array called R. So element in R like this. So this will go through each element, sorry, this should be element. So I want to print the element. So it will go through each element in R and assign that to element one by one. And then we print that element. Okay. Right. One more little syntactic details. So you can do. No, I don't want to use the word string because that's a type name. Well, you can use string without the capital S string in. So you can also use the in character which you type by. So you have to type one more letter you have to type the slash. And then you have to type tab at the end. So if you think that looks a lot nicer, you can do this. So let's have some strings here for string in whole bar. Buzz just print the strings. And now again, we have a couple of exercises. It's basically 11. So we have finished the first section and we are an hour late from what I was intending. I hope this was useful. But maybe we need to make this section a bit faster.