Skip to content

Commit

Permalink
fix #10540
Browse files Browse the repository at this point in the history
specialize map!(f,A) as well
  • Loading branch information
tkelman committed Mar 17, 2015
1 parent b201312 commit 2a4fd44
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ function map_promote(f, A::AbstractArray)
end

## 1 argument
map!(f, A::AbstractArray) = map!(f, A, A)
map!{F}(f::F, A::AbstractArray) = map!(f, A, A)
function map!{F}(f::F, dest::AbstractArray, A::AbstractArray)
for i = 1:length(A)
dest[i] = f(A[i])
Expand Down
6 changes: 5 additions & 1 deletion test/functional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

# map -- array.jl
@test isequal(map((x)->"$x"[end:end], 9:11), ["9", "0", "1"])
# TODO: @test map!()
# TODO: @test map!() much more thoroughly
let a = [1.0, 2.0]
map!(sin, a)
@test isequal(a, sin([1.0, 2.0]))
end
# map -- ranges.jl
@test isequal(map(i->sqrt(i), 1:5), [sqrt(i) for i in 1:5])
@test isequal(map(i->sqrt(i), 2:6), [sqrt(i) for i in 2:6])
Expand Down

0 comments on commit 2a4fd44

Please sign in to comment.