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}}