Re: List searching
- To: mathgroup at smc.vnet.net
- Subject: [mg57577] Re: [mg57512] List searching
- From: János <janos.lobb at yale.edu>
- Date: Wed, 1 Jun 2005 06:03:01 -0400 (EDT)
- References: <200505310859.EAA03316@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On May 31, 2005, at 4:59 AM, Guy Israeli wrote:
> 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
In[16]:=
moreThanOnce[x_List] :=
If[Last[Sort[Length /@
Split[Sort[lst]]]] >
1, True, False]
>
> - tests if there is an element in the list that is bigger/smaller
> than a
> certain number
In[30]:=
lst = Table[Random[Integer,
{0, 9}], {i, 20}]
Out[30]=
{4, 1, 0, 3, 0, 5, 5, 2, 5,
3, 4, 5, 2, 5, 1, 8, 0, 5,
0, 1}
In[29]:=
a = 7.2
Out[29]=
7.2
In[36]:=
Select[lst, #1 > a & ]
Out[36]=
{8}
>
> I would really appreciate your help,
>
> Guy
>
>