RE: Error Testing a List on input
- To: mathgroup at smc.vnet.net
- Subject: [mg37721] RE: [mg37685] Error Testing a List on input
- From: "David Park" <djmp at earthlink.net>
- Date: Sat, 9 Nov 2002 00:30:45 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Flip, Something like this. fliptest = Head[#] === Integer && 0 <= # <= 9 &; list1 = {1.0, 3, 7, 14, 2.5}; list2 = {2, 7, 3, 6, 5}; fliptest /@ list1 And @@ % {False, True, True, False, False} False And @@ fliptest /@ list2 True David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: flip [mailto:flip_alpha at safebunch.com] To: mathgroup at smc.vnet.net 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