Oops:  prod, not sum:

function Base.reshape{N}(a::AbstractArray, dims::NTuple{N,Union(Int,())})
    missing_mask = [isa(x,Tuple) for x in dims]
    sum(missing_mask) == 1 || throw(DimensionMismatch("new dimensions 
$(dims) may only have up to one omitted dimension"))
    sz = length(a) / prod(dims[!missing_mask])
    sz == int(sz) || throw(DimensionMismatch("array size $(length(a)) must 
be divisible by the product of the new dimensions $(dims[!missing_mask])"))
    reshape(a,map(x->isa(x,Tuple) ? int(sz) : x, dims))
end

Reply via email to