julialangHow to use the map function in JuliaLang?
The map
function in JuliaLang is used to apply a function to each element of a collection. It takes two arguments, the first being the function to be applied and the second being the collection.
Example
julia> map(x -> x^2, [1,2,3,4])
4-element Array{Int64,1}:
1
4
9
16
Code explanation
map
: the function to be usedx -> x^2
: the function to be applied to each element of the collection[1,2,3,4]
: the collection
Helpful links
More of Julialang
- How to get JuliaLang version?
- How to use tuples in JuliaLang?
- How to set up logging in JuliaLang?
- How to use regular expressions in JuliaLang?
- How to use the println function in JuliaLang?
- How to test code in JuliaLang?
- How to use constructors in JuliaLang?
- How to use try catch in JuliaLang?
- How to round numbers in JuliaLang?
- How to work with matrices in JuliaLang?
See more codes...