Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Documentation
binarySearchRational :: Integer -> (Rational -> Ordering) -> (Rational, Rational) Source #
>>>
binarySearchRational 100 (\x -> compare (x * x) 2)
(140 % 99,99 % 70)>>>
map (fromRational @Double) [140 % 99, 99 % 70]
[1.4141414141414141,1.4142857142857144]>>>
binarySearchRational (10^10) (`compare`(1 % (10^10)))
(1 % 10000000000,1 % 9999999999)>>>
binarySearchRational (10^10) (`compare`((10^10-1) % (10^10)))
(9999999999 % 10000000000,1 % 1)