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 set up logging in JuliaLang?
- How to create a package in JuliaLang?
- How to solve differential equations in JuliaLang?
- How to use lambda functions in JuliaLang?
- How to animate in JuliaLang?
- How to use addprocs in JuliaLang?
- How to test code in JuliaLang?
- How to use assert in JuliaLang?
- How to use tuples in JuliaLang?
- How to sort in JuliaLang?
See more codes...