Skip to content

Instantly share code, notes, and snippets.

@nalimilan
Created October 23, 2016 15:16
Show Gist options
  • Save nalimilan/32c86f9ca809a08ecbdec3ecbd3a92f5 to your computer and use it in GitHub Desktop.
Save nalimilan/32c86f9ca809a08ecbdec3ecbd3a92f5 to your computer and use it in GitHub Desktop.
function sumequals{T}(A::AbstractArray{Int}, d::Dict{T, Int}, v::T)
n = 0
@inbounds for x in A
n += get(d, v, 0) == x
end
n
end
A = repeat(1:5, outer=1000)
d = Dict("A"=>1, "B"=>2, "C"=>3)
sumequals(A, d, "C")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment