 So a quick example of flow control inside of a function So I've created a new function here call it flow function and flow funk and I am using a Variable number of arguments by using these ellipses or splat and what I'm going to do say print I can tell you how many arguments you passed. I'm going to use this inbuilt Julia function length again Which is just going to count the number of arguments that are passed and then Remember, this is a new line character and I'm going to have this Variable called I and I'm going to set it I equals one and It doesn't exist outside of my function You remember it's here. It's inside of a function and now I have a for loop inside of a function So I'm going to iterate over all the arguments that I've passed by using this for N in arguments Then I'm going to print a line argument and Then I remember I Is one at the moment and We pass a tab in and remember that is going to go through these arguments one by one and Then a new line and then we're going to Increment I by one so I equals I plus one or short end I plus equals one We're going to end our for loop and then we're going to end our function So you see there's a little bit of a problem here with the indentation Don't indent quite properly in I Julia. It doesn't matter. It will still work So let's run that function. Let's create that function and now let's call it and I'm going to pass All of these arguments again Julia is one in a million two of them are values the rest are strings and Look what it's done So as says I can tell you how many arguments you've passed there was seven and then it's going to run through the for loop so it's going to print argument then I remember I was one and Because it is looping through this end. So the first time it goes through it'll be one So the first argument was Julia now we increment I by one So the next time we run through I is now to so it's going to print argument two to the screen N is now incremented to two. So that'll be the second argument that I passed and so on so quite nice Now though, let's pass some arrays as a function arguments So we've created these functions. We've created these arguments. We've even created the keyword arguments We've created the user use the splat to create an infinite number possible infinite number of arguments But what if I wanted to not pass a single value, but I wanted to pass a whole array So let's create a ray or column vector here by the factor I create this computer variable called x valves and the square brackets indicate the fact that it is an array So it looks like I'm going from negative three to three and I'm incrementing by a half So that's in a ray of values. Let's create there. We are negative three to three Now let's create a function and I'm going to call my function sqr It's going to take a single argument called a and it's going to return a squared And then end so it's a generic function with a single method now Let's map. Let's use the map function. That is one way to use To use a function and then as an argument instead of passing a single value. We pass in whole array. So it's map Then I call my function and I don't use the parentheses and then pass an argument I say comma and then So and then x val so I'm mapping the array to the function and There we go It's going to take every element and it's going to square so three becomes nine Negative three becomes nine and negative two point five becomes six point two five, etc Now I've left this out, but you can certainly do get fly to plot this and you'll see beautifully the x squared pattern that you will see now Let's just have a look at something Map is not always the best thing to do some of the functions leased in In Julia the inbuilt functions. They have their own inbuilt mapping And I'm going to use this macro called at time which will tell me how much time it takes to execute this line of code And how much memory was used so Remember in some older text you will see this using this one dot 10,000 with a square brackets. That's really been deprecated. We we now use in Julia. We use the collect syntax So I'm going to map the sign function and I'm going to do the sign function for values from 1 to 10,000 So the sign of 1 sign of 2 sign of 3 sign of 4 sign of 5 signs it going to go through that 10,000 times let's see what happens that took 0.03 seconds and it used 1.29 megabytes of memory Now let's time it again, but instead of mapping I'm just going to use the inbuilt so sign can map an array to it as part of an Inbuilt ability and look at the difference now It only used 0.009 seconds and only 361 kilobytes a lot less memory and a lot faster and A lot faster than using the map function. So maps not always ideal. We also have this problem When we use arrays now remember the raise the square brackets tuples Assistus list with these parentheses if I have a function it takes two arguments and that it returns three times x plus two times y I cannot call that function h with an array or with a tuple. I'm going to get an error when I do that now one way to get Around it is the apply function But that's been deprecated as well. We now rather use the splat or ellipses So let's create our array three and four and our tuple three and four Let's have that and now create our function h which takes two arguments three times x plus two times y and Instead of just passing that array or tuple as an argument. I use it as a splat So h and array one splat and tuple one splat and you can see what happens It's going to pass three to the x and four to the y So that would be one easy way of passing these Arrays to a function Now except for numbers and characters or other plain data values of arguments are passed by reference only and are not Copied as you can read there They can therefore be altered. So let's have a look at this I'm going to create this computer variable called array underscore primes I'm going to pass it as an array by the square brackets one two three five seven eleven thirteen seventeen and nine and We're going to have an argument as to whether one is a prime number or not. Certainly Julia It's not but we can have that argument elsewhere. So there's my array Nine element array in a single column. They're all 64 bit integers. So let's create this function called add underscore eally add element and I've got a single argument there a and it's going to use the internal The inbuilt Julia function push with this exclamation mark, which means add to the end So it's going to take my argument and it's going to slob on 23 at the end That's what the push exclamation mark will use that term for now push this exclamation mark does So let's run it and we passed to it the array of primes So I'm again passing an array To I'm passing an array to a function and look what happened that 23 was lobbed on at the back And that's permanent because if I call array primes now It's there. It is still there Okay, so for now, we've just passed these normal arguments or keyword arguments or Splat number of arguments, but we can be much more precise in what type of arguments we want to allow We can control that and we call that using type parameters or a parametric method and that is up next