From the course: Learning Julia

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Vectorization operator

Vectorization operator - Julia Tutorial

From the course: Learning Julia

Start my 1-month free trial

Vectorization operator

- [Instructor] When working with sets of data, it's fairly common to have to apply a transformation to all of the data items in a collection. And some languages provide a map function for this but Julia actually has a built in operator that performs this function as part of the language itself. It's called the vectorization operator and sometimes it's just known as the dot operator because of the syntax. So let's see how this works. And I'm going to open up the vector_start file. So here I have an array of some data and we're going to learn more about arrays later in the course, but for now just know that an array is a list of data items. So let's suppose I wanted to multiply each of these data items by two. Now I could do that by looping over each item in the array and multiplying each one, but it's much easier to use the dot notation. So here's what I'm going to do. I'm going to write result is equal to array1 and then I'm going to put a dot operator and then the operator I want to…

Contents