Re: selecting from lists

• To: mathgroup at smc.vnet.net
• Subject: [mg6222] Re: [mg6184] selecting from lists
• From: Jens Potschadtke <Jens.Potschadtke at stud.uni-erlangen.de>
• Date: Fri, 28 Feb 1997 03:21:41 -0500
• Organization: Institute for Biomedical Engineering at the FAU Erlangen
• Sender: owner-wri-mathgroup at wolfram.com

```Frans Martens wrote:
>
> Murray wrote:
>
> The problem: given an arbitrary list v and a list b of the same
> length, whose entries are all Boolean (True or False), construct a
> function s[v, b] whose result is a list consisting only of those
> entries of v for which the corresponding entries in b are True.  For
> example,
>
>    v = {3, 82, 7, -12, 5};
>    b = {False, True, True, False, False};
>    s[v, b]
>    {82, 7}
>

[...]
>
> Yes, there is a more direct way! I have added some computations.
>
>    t[v_,b_] := Cases[Transpose[{v,b}],{a_,True}:>a]
>

You can also give a try to the solution of the wolfram-folks,
because there exists a predefined function:

<<Statistics`DataManipulation`
BooleanSelect[v,b]

----
Jens Potschadtke
Institute for Biomedical Engineering at the University of Erlangen
(Germany)
mailto:Jens.Potschadtke at stud.uni-erlangen.de
http://www.uni-erlangen.de/~sz0438/

```

• Prev by Date: Re: f[x] as top axis in ListPlot
• Previous by thread: Re: selecting from lists
• Next by thread: Re: "pretty printing" input cells