I want to test if an expression is a vector of all reals. I defined
RealVector[expr_]:=VectorQ[expr,NumberQ[#]&&(Head[#]===Real)];
Trying this on
RealVector[{1,2,3}]; RealVector[{1.,2.,3.}];
should return False and True, resp., but I get False and False. I do not
understand what is wrong. Can you help me to fix it?
&after the pure function. UseNumberQ[#]&&(Head[#]===Real) &. Note the&at the end. The#signs should show as green in the notebook when used correctly, not pink. – Szabolcs Jan 27 '15 at 17:19realVectorQ[{___Real}] = True; realVectorQ[__] = False– Szabolcs Jan 27 '15 at 17:21realVector[expr_] := VectorQ[expr, # \[Element] Reals && # \[NotElement] Integers &]– David G. Stork Jan 27 '15 at 18:06