Re: Error Testing a List on input
- To: mathgroup at smc.vnet.net
- Subject: [mg37724] Re: [mg37685] Error Testing a List on input
- From: Tomas Garza <tgarza01 at prodigy.net.mx>
- Date: Sat, 9 Nov 2002 00:30:53 -0500 (EST)
- References: <200211080716.CAA07421@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Try these:
In[1]:=
data={1,3.23,-12,9.5,8.9,2,5,8,-4};
In[2]:=
If[Union[IntegerQ /@ data] != {True}, Print["ouch!"]]
ouch!
In[3]:=
If[Union[(#1 >= 0 & ) /@ data] != {True}, Print["ouch!"]]
ouch!
In[4]:=
If[Union[(#1 <= 9 & ) /@ data] != {True}, Print["ouch!"]]
ouch!
Tomas Garza
Mexico City
----- Original Message -----
From: "flip" <flip_alpha at safebunch.com>
To: mathgroup at smc.vnet.net
Subject: [mg37724] [mg37685] Error Testing a List on input
> Hello,
>
> I was wondering if there is an easy way to do this.
>
> I want to input a list of nine numbers. I would like to test each element
in
> the list prior to acting upon it.
>
> This ends up being a sort of error check on the list prior to manipulating
> it, if it is wrong, produce an error message or do nothing with the
module.
>
> So, I would like to test each element to be a. an integer, b. >= 0, c. <=
9.
>
> Is there a way to test this list at the input prior to acting upon it?
>
> Thanks, Flip
>
>
>
>
- References:
- Error Testing a List on input
- From: "flip" <flip_alpha@safebunch.com>
- Error Testing a List on input