fork download
  1. import Data.List (findIndex)
  2. xs = [(0,1),(1,2),(2,4),(4,8)]
  3. f x xs = (+1) <$> findIndex (\(a,b) -> (a <= x) && (x < b)) xs
  4. main = print $ f 1.5 xs
Success #stdin #stdout 0s 8388607KB
stdin
Standard input is empty
stdout
Just 2