binary-search

Binary and exponential searches

Version on this page:0.9@rev:1
LTS Haskell 22.18:2.0.0
Stackage Nightly 2024-04-26:2.0.0
Latest on Hackage:2.0.0

See all snapshots binary-search appears in

BSD-3-Clause licensed by Ross Paterson, Takayuki Muranushi
Maintained by Takayuki Muranushi
This version can be pinned in stack with:binary-search-0.9@sha256:ff81086a6f6d1dbbe670683d479813d5897cc5bcc12bac1ed600164e20b37631,3283
Depends on 2 packages(full list with versions):
Used by 1 package in nightly-2016-01-19(full list with versions):

Introduction

This package provides varieties of binary search functions.

These search function can search for predicates of the type pred :: (Integral a, Eq b) => a -> b, or monadic predicates pred :: (Integral a, Eq b, Monad m) => a -> m b. The predicates must satisfy that the domain range for any codomain value is continuous; that is, ∀x≦y≦z. pred x == pred z ⇒ pred y == pred x .

For example, we can address the problem of finding the boundary of an upward-closed set of integers, using a combination of exponential and binary searches.

Variants are provided for searching within bounded and unbounded intervals of both Integer and bounded integral types.

The package was created by Ross Paterson, and extended by Takayuki Muranushi, to be used together with SMT solvers.

The Module Structure

  • Numeric.Search.Combinator.Monadic provides the most generic combinators. Numeric.Search.Combinator.Pure provides the pure version of them.

  • Numeric.Search exports both pure and monadic version.

  • Numeric.Search.Bounded , Numeric.Search.Integer , Numeric.Search.Range provides the various specialized searchers, which means less number of function arguments, and easier to use.