Re: List searching
- To: mathgroup at smc.vnet.net
- Subject: [mg57551] Re: [mg57512] List searching
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Wed, 1 Jun 2005 06:01:36 -0400 (EDT)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
To test whether any element occurs more than once:
data={a,b,c,d,e,f,a};
Length[data]!=Length[Union[data]]
True
To test whether any element exceeds a number
data=Sort[Table[Random[],{10}]]
{0.0629574, 0.0832333, 0.21535, 0.244962, 0.30882,
0.417552, 0.550512, 0.610004, 0.857675, 0.979753}
The numbers are sorted to make it easy to verify the results; sorting is not
required.
Count[data, _?(#>0.85&)]>0
True
Bob Hanlon
>
> From: Guy Israeli <guyi1 at netvision.net.il>
To: mathgroup at smc.vnet.net
> Date: 2005/05/31 Tue AM 04:59:03 EDT
> Subject: [mg57551] [mg57512] List searching
>
> Hello,
>
> I needed to test lists for certain elements inside of it, however, since I
> didn't find the proper function I had to write them myself.
>
> are there functions that can do the following:
>
> - tests (returns true or false) if within the list there is an element that
> appears more than once
>
> - tests if there is an element in the list that is bigger/smaller than a
> certain number
>
> I would really appreciate your help,
>
> Guy
>
>
>
Bob Hanlon
Chantilly, VA