Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Mapping A Condition Across Two Different Lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg91771] Re: Mapping A Condition Across Two Different Lists
  • From: Steven Siew <stevensiew2 at gmail.com>
  • Date: Sun, 7 Sep 2008 05:39:43 -0400 (EDT)
  • References: <g9t6k5$j6g$1@smc.vnet.net>

targetX=5;
listX={4,9,2,11,4};
targetX>#&/@listX

{True,False,True,False,True}

targetY = 3;
listY = {4, 0, 1, 8, 6};
targetY > # & /@ listY

{False,True,True,False,False}

You can do them both together with

Map[  targetX > #[[1]] && targetY > #[[2]] & ,
Thread[List[listX,listY]]  ]

{False, False, True, False, False}


Map[  targetX > #[[1]] || targetY > #[[2]] & , Thread[List[listX,
listY]]  ]

{True, True, True, False, True}

This is done basicall by using the concept of Zip[]

defined as

Zip[listA_,listB_] := Thread[List[listA, listB]]

Zip[listX, listY]

{{4, 4}, {9, 0}, {2, 1}, {11, 8}, {4, 6}}


  • Prev by Date: Re: phase-space versus controlling parameter surface
  • Next by Date: Re: Mapping and AppendTo
  • Previous by thread: Mapping A Condition Across Two Different Lists
  • Next by thread: Re: Mapping A Condition Across Two Different Lists