MathGroup Archive 2008

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

Search the Archive

Re: Mapping A Condition Across Two Different Lists


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