how do i filter a list of tuples with int int values by a predicate applied to their respective first and second values?

To test if a tuple (Int,Int) is in a given range, you can use the inRange function:

import Data.Ix (inRange)

inRange ((1,1),(10,10)) (5,5)                    -- True
inRange ((1,1),(10,10)) (11,6)                   -- False

filter (inRange ((1,1),(10,10))) [(5,5),(11,6)]  -- [(5,5)]

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top