MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: List searching


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

Try this:

      redundancy[ alist_] := Length[ alist] != Length[ Union[ alist ] ]

>
> - tests if there is an element in the list that is bigger/smaller  
> than a
> certain number

      containsGreater[ alist_, x_] :=  Max[ alist ] > x

      containsLesser[ alist_ , x_] :=  Min[ alist ] < x


------------
Selwyn Hollis
http://www.appliedsymbols.com




  • Prev by Date: Re: reducing the time of constructing a List
  • Next by Date: Re: opposite of partition
  • Previous by thread: Re: FourierTransform
  • Next by thread: Re: List searching