# Sum of Integers with a Pure Function

How would I find the sum of an argument, with the constraint that they are all integers (so if the argument contains a non-integer value, the function will not evaluate).

I came up with these two:

sumInts[n__?(IntegerQ[#] &)] := +n

and

sum[x__Integer] := +x

Both are impure functions (though the first function uses a pure predicate). How would I go about making a pure function? I couldn't figure out how to because of the Integer constraint.

Thanks!

f := (If[AllTrue[{##}, IntegerQ] , +##]) &

• More classically: MatchQ[{##}, {__Integer}]. – J. M. is away Jun 25 '15 at 8:55