Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Mapping tag-value lists to a third
Replies: 8   Last Post: Mar 23, 2014 5:00 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bob Hanlon

Posts: 906
Registered: 10/29/11
Re: Mapping tag-value lists to a third
Posted: Mar 18, 2014 1:28 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


tag = {0, 1, 0, 0, 0, 1, 0, 1};

val = {f1, f2, f3, f4, f5, f6, f7, f8};


Pick[val, tag, 1]


{f2, f6, f8}



Bob Hanlon




On Mon, Mar 17, 2014 at 2: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.
>




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.