Sum of Elements in an Array

Suppose we generate an array of \(500\) elements and look at the sums made by adjacent items. Then we build a frequency dictionary and look at how many ways we are able to

@time begin
    X = [ rand(0:100) for _ in 1:500 ]

    p1 = 1
    p2(p, windowsize) = p + windowsize
    fhist = Dict{Int64, Int64}()

    for ws in 1:(length(X)-1)
        for p in 1:(length(X)-ws)
            lo = p
            hi = p2(p, ws)

            s = X[lo:hi] |> sum
            if haskey(fhist, s)
                fhist[s] += 1
            else
                fhist[s] = 1
            end
        end
    end

    bar([keys(fhist)...], [values(fhist)...])
end