MathGroup Archive 1997

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

Search the Archive

Re: How do I use BooleanSelect?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg6404] Re: [mg6390] How do I use BooleanSelect?
  • From: "w.meeussen" <w.meeussen.vdmcc at vandemoortele.be>
  • Date: Sun, 16 Mar 1997 19:25:19 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

At 01:21 15-03-97 -0500, jason welter wrote:
>
>BooleanSelect is a function in the DataManipulation.m add on package
>in Statistics.  It doesn't seem to work.  Here's some background on it
>as well as TakeWhile which does work:
>
>??BooleanSelect
>
>"BooleanSelect[list, sel] keeps elements of list for which the
>corresponding element of sel is True."
>Attributes[BooleanSelect] = {Protected, ReadProtected}
>
>??TakeWhile
>
>"TakeWhile[list, pred] takes elements from the beginning of list while
>pred is True."
>Attributes[TakeWhile] = {Protected, ReadProtected}
>
>Here is some test data I have been using to explore these functions:
>
>testa = {1,2,3,4,-2,y,6,7};
>testb={{1,2},{-2,3},{23,56},{90,54},{-2,-200}};
>
>The function TakeWhile works in the following way:
>
>TakeWhile[testa,NumberQ]
>
>Out[16]={1,2,3,4,-2}
>
>Boolean Select does not:
>
>BooleanSelect[testa,NumberQ]
>
>Out[21]=BooleanSelect[{1,2,3,4,-2,y,6,7},NumberQ]
>
>What I really need is a working function like BooleanSelect that will
>let me sort through arrays, like "testb".  I need to screen out all
>groups in testb that either have -2 or -200 as an element.  For
>example:
>
>BooleanSelect[testb,???]
>
>{{1,2},{23,56},{90,54}};
>
>There must be a way.  What is it?
>
>

try:

In[157]:=
Cases[testb,{a_/;(a!=-2),b_/;(b!=-200)}]
Out[157]=
{{1,2},{23,56},{90,54}}

it looks like BooleanSelect takes as second argument a list of 
"corresponding element(s)" each True or False.

that you can generate with:
Cases[testb,{a_,b_}->(a!=-2)&&(b!=-200)]

have fun,

wouter.



Dr. Wouter L. J. MEEUSSEN
eu000949 at pophost.eunet.be
w.meeussen.vdmcc at vandemoortele.be



  • Prev by Date: system of equations
  • Next by Date: Re: Working with Dot[..] or NonCommutativeMultiply[..]
  • Previous by thread: How do I use BooleanSelect?
  • Next by thread: Why does TimeUsed die?