November 2016
Intermediate to advanced
697 pages
14h 44m
English
In this section, we will demonstrate the power and flexibility of functions (example code can be found in chapter 3\first_class.jl). First, functions have their own type: typing typeof(mult) in the REPL returns Function. Functions can also be assigned to a variable by their name:
julia> m = mult julia> m(6, 6) #> 36.
This is useful when working with anonymous functions, such as c = x -> x + 2, or as follows:
julia> plustwo = function (x) x + 2 end (anonymous function) julia> plustwo(3) 5
Operators are just functions written with their arguments in an infix form, for example, x + y is equivalent to +(x, y). In fact, the first form is parsed to the second form when it is evaluated. We can confirm it in the ...
Read now
Unlock full access