Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #16675

Re: Mapping tag-value lists to a third

From Carl K Woll <carlw@wolfram.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Mapping tag-value lists to a third
Date 2014-03-20 09:27 +0000
Message-ID <lgecah$7o8$1@smc.vnet.net> (permalink)
References <20140317062731.30FA06A09@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


On 3/17/2014 1:27 AM, carlos.felippa%colorado.edu@gtempaccount.com wrote:
> Hi,
>
> I have 2 lists of equal length such as
>
> tag={0, 1, 0, 0, 0, 1, 0, 1};  val={f1,f2,f3,f4,f5,f6,f7,f8}
>
> and want to produce a third:
>
> tagval={f2,f6,f8}
>
> with length Count[tag,1] containing the entries of val marked by 1-tags. Should be
> something efficient, since the source lists may be large (10^6 to 10^7).  Thanks.
>

I think Pick is what you want:

In[366]:= Pick[val, tag, 1]

Out[366]= {f2, f6, f8}

Carl Woll

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar


Thread

Re: Mapping tag-value lists to a third Carl K Woll <carlw@wolfram.com> - 2014-03-20 09:27 +0000

csiph-web