Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # How does map determine the correct type for the output of the following two map calls? Does it assume the array all has the same type as `f(a[1])` and put things into a `Vector{Any}` after seeing that the types are not the same?
- julia> a = [1, 2, 3]
- 3-element Array{Int64,1}:
- 1
- 2
- 3
- julia> f(x) = (x == 1) ? "a" : 0
- f (generic function with 1 method)
- julia> map(f, a)
- 3-element Array{Any,1}:
- "a"
- 0
- 0
- julia> f(x) = (x == 1) ? 1 : 0
- f (generic function with 1 method)
- julia> map(f, a)
- 3-element Array{Int64,1}:
- 1
- 0
- 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement