diff --git a/src/Compat.jl b/src/Compat.jl index 3bb26dd13..53ed113c2 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -985,6 +985,7 @@ macro functorize(f) if VERSION >= v"0.5.0-dev+3701" f === :scalarmax ? :(Base.scalarmax) : f === :scalarmin ? :(Base.scalarmin) : + f === :centralizedabs2fun ? :(typeof(Base.centralizedabs2fun(0)).name.primary) : f else f = f === :identity ? :(Base.IdFun()) : @@ -998,6 +999,7 @@ macro functorize(f) f === :* ? :(Base.MulFun()) : f === :scalarmax ? :(Base.MaxFun()) : f === :scalarmin ? :(Base.MinFun()) : + f === :centralizedabs2fun ? :(Base.CentralizedAbs2Fun) : f if VERSION >= v"0.4.0-dev+4902" f = f === :< ? :(Base.LessFun()) : diff --git a/test/runtests.jl b/test/runtests.jl index b705d99e4..b390f17d0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1086,3 +1086,8 @@ end let a = rand(1:10, 10) @test mapreduce(identity, dot, a) == mapreduce(identity, @functorize(dot), a) end +@test isa(@functorize(centralizedabs2fun)(1), @functorize(centralizedabs2fun)) +@test isa(@functorize(centralizedabs2fun)(1.0), @functorize(centralizedabs2fun)) +let a = rand(1:10, 10) + @eval @test mapreduce(x -> abs2(x - 1), +, $(a)) == mapreduce(@functorize(centralizedabs2fun)(1), +, $(a)) +end