I use the following to get the (untyped) powerset of an array:
function powerset (x)
result = {{}}
for i in x, j = 1:length(result)
push!(result, [result[j],i])
end
result
end
julia> show(powerset(1:3))
{{},{1},{2},{1,2},{3},{1,3},{2,3},{1,2,3}}
Then sdifsums can be written as
sdifsums(a) = sum(a).-[2sum([a[i] for i=s]) for s=powerset([1:length(a)])]
If performance matters, one should type everything and deal with the sums
in powerset itself when the subsets are computed. Probably slower than your
approach. At least the powerset function seems to have an interest on its
own.