MathGroup Archive 1997

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

Search the Archive

Re: prograMing: split a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg8958] Re: prograMing: split a list
  • From: Leszek Sczaniecki <lsczan at concentric.net>
  • Date: Mon, 6 Oct 1997 01:59:26 -0400
  • Organization: Concentric Internet Services
  • Sender: owner-wri-mathgroup at wolfram.com


Leszek Sczaniecki wrote:

> What about this solution?
>
> In[1]:= myList=Table[Random[Integer,{1,200}],{10000}];
>
> In[2]:= fQ=OddQ;
>
> In[3]:= {Select[myList, fQ], Select[myList,!fQ]} ;// Timing
> Out[3]= {0.15 Second,Null}
>

[...]

Here is an appendix to my last posting. Michael Trott just reminded me that this
will not work for completely general, user defined boolean function fQ. In that
case you need to do something like that

    {Select[myList, fQ], Select[myList,!fQ[#]&]}

or, if you care about the symmetry of the last expression, define two tests fQ and
notfQ

    fQ := (# < 100)&
    notfQ := (# >= 100)&     (or not fQ := !fQ[#]&)

   {Select[myList, fQ], Select[myList,notfQ]}


Leszek




  • Prev by Date: Handling data and Images
  • Next by Date: Re: lost Greek letters in graphics (EPS files)
  • Previous by thread: Re: prograMing: split a list
  • Next by thread: Re: prograMing: split a list