May 2019
Beginner to intermediate
466 pages
10h 44m
English
Because, in Julia, functions are first-class language constructs, they can be referenced and manipulated like any other type of variable. They can be passed as arguments to other functions or can be returned as the result of other function calls. The functions that take another function as their argument or return another function as their result are called higher-order functions.
Let's look at a simple example using map. We'll take a Vector of Int, and we'll apply to each element of its collection a function that doubles the value. You can follow along in a new REPL session (or in the accompanying IJulia notebook):
julia> double(x) = x*2 double (generic function with 1 method) julia> map(double, [1, 2, 3, 5, 8, 13]) 6-element ...
Read now
Unlock full access