
10 Nov
2010
10 Nov
'10
10:13 a.m.
2010/11/10 C K Kashyap
Hi, I have this problem at hand -
Given two lists
list1 = [0,1,2,0,1,4]
list2 = [1,2,3,4,5,6] I need to take items from the second list only when the corresponding item in list1 is non-zero.
Another wayOne way to do it, although not shorter : list3 = catMaybes $ zipWith (\a b -> if a > 0 then Nothing else Just b) list1 list2 David.