Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*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 smc.vnet.net
  • Subject: [mg19073] Re: Lists to mask other lists
  • From: "David Bailey" <db at salford-software.com>
  • Date: Thu, 5 Aug 1999 01:34:58 -0400
  • Organization: University of Salford, Salford, Manchester, UK
  • References: <7o5hi2$rkt@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

aram schiffman <aram at sirius.com> wrote in message
news:7o5hi2$rkt at smc.vnet.net...
> 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 corresponding
> element of realDealList alone. But if a 0 appears, then I want to change
> the corresponding element of realDealList in some prescribed way. Let's
> 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?

MapThread is the answer because it lets your function operate on
corresponding elements from several lists:

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

David Bailey
Salford Software





  • Prev by Date: Re: How to prevent a window from being resized?
  • Next by Date: Re: HELP : Mathematica v4 producing erroneous results ! Mathematica3 worked fine...
  • Previous by thread: Re: Lists to mask other lists
  • Next by thread: Re: Lists to mask other lists