MathGroup Archive 2014

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

Search the Archive

Re: Mapping tag-value lists to a third

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132446] Re: Mapping tag-value lists to a third
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Tue, 18 Mar 2014 01:28:24 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <20140317062731.30FA06A09@smc.vnet.net>

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 at 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.
>


  • Prev by Date: Re: Mapping tag-value lists to a third
  • Next by Date: Re: Mapping tag-value lists to a third
  • Previous by thread: Re: Mapping tag-value lists to a third
  • Next by thread: Re: Mapping tag-value lists to a third