Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

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

Search the Archive

Re: Lists to mask other lists

  • To: mathgroup at
  • Subject: [mg19076] Re: Lists to mask other lists
  • From: dkeith at
  • Date: Thu, 5 Aug 1999 01:35:00 -0400
  • References: <7o5hi2$>
  • Sender: owner-wri-mathgroup at

Hi Aram,

MapThread will work. I use a pure function, but you can define one with
a name if you like.

maskList = {1, 0, 0, 1, 1};

realDealList = {aaa, bbb, ccc, ddd, eee};

MapThread[If[#1 == 1, #2, "aram"] &, {maskList, realDealList}]

{aaa, "aram", "aram", ddd, eee}

 article <7o5hi2$rkt at>,
  aram schiffman <aram at> wrote:
> Howdy.
> I am trying to use one list to control the content of a second list.
> (It's not really masking, but...)
> Here's what I mean. Let's say
> maskList={1,0,0,1,1}
> realDealList={aaa,bbb,ccc,ddd,eee}
> (* could be filled with anything; same # elements as maskList }
> If a 1 appears at position n of maskList, then I leave the
> element of realDealList alone. But if a 0 appears, then I want to
> the corresponding element of realDealList in some prescribed way.
> say I change those elements to my first name (aram). Then realDealList
> would become
> {aaa,aram,aram,ddd,eee}
> I can do this in a loop, which is a really clunky solution, but isn't
> there a way I can Map across my list somehow?
> Thanks,
> Aram Schiffman

Sent via
Share what you know. Learn what you don't.

  • Prev by Date: RE: Showing a limited GrayLevel
  • Next by Date: Employment Opportunity - Calculus Developer
  • Previous by thread: RE: Lists to mask other lists
  • Next by thread: Re: Lists to mask other lists