Sorry reduce was a bad idea, even if syntax is nice, it's really slow and
greedy.

V1 can take advantage of @inbounds and @simd optimizations:
http://docs.julialang.org/en/release-0.5/manual/performance-tips/#performance-annotations

I hope reduce will be optimized in future because here it expresses rightly
the problem we solve and has a nice syntax:

mapeBase_v4(A::Vector{Float64}, F::Vector{Float64}) = reduce((0.0, 0),
enumerate(A)) do result::Tuple{Float64, Int64}, current::Tuple{Int64,
Float64}
    current[2] == 0.0 && return result # guard clause
    result[1] + abs( 1 - F[current[1]] / current[2]), result[2] + 1
end

unfortunately it's unusable ;)


2016-10-26 8:01 GMT+02:00 Martin Florek <martin.flo...@2bridgz.com>:

> Thank you everyone. v1 is very nice, as it turned out. I was looking for
> the magic of language Julia especially for the generator.
>

Reply via email to