We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 811e1ea commit b1034b8Copy full SHA for b1034b8
src/list.jl
@@ -79,7 +79,9 @@ function Base.map(f::Base.Callable, l::Cons{T}) where T
79
push!(stack, head(l))
80
l::Cons{T} = tail(l)::Cons{T}
81
end
82
- l2 = list(f(head(l))) # Note this might have a different eltype than T
+ # Note the new list might have a different eltype than T
83
+ first = f(head(l))
84
+ l2 = cons(first, nil(typeof(first) <: T ? T : typeof(first)))
85
for i in reverse(1:length(stack))
86
l2 = cons(f(stack[i]), l2)
87
0 commit comments