Safe Haskell | None |
---|---|
Language | Haskell2010 |
AOC.Common.Search
Synopsis
- aStar :: forall n p. (Ord n, Ord p, Num p) => (n -> p) -> (n -> Map n p) -> n -> (n -> Bool) -> Maybe (p, [n])
- bfs :: forall n. Ord n => (n -> Set n) -> n -> (n -> Bool) -> Maybe [n]
- binarySearch :: (Int -> Ordering) -> Int -> Int -> Maybe Int
- exponentialSearch :: (Int -> Ordering) -> Int -> Maybe Int
- binaryMinSearch :: (Int -> Bool) -> Int -> Int -> Maybe Int
- exponentialMinSearch :: (Int -> Bool) -> Int -> Maybe Int
- binaryFindMin :: (Int -> Maybe a) -> Int -> Int -> Maybe a
- exponentialFindMin :: (Int -> Maybe a) -> Int -> Maybe a
Documentation
Arguments
:: forall n p. (Ord n, Ord p, Num p) | |
=> (n -> p) | heuristic |
-> (n -> Map n p) | neighborhood |
-> n | start |
-> (n -> Bool) | target |
-> Maybe (p, [n]) | the shortest path, if it exists, and its cost |
A* Search
Arguments
:: forall n. Ord n | |
=> (n -> Set n) | neighborhood |
-> n | start |
-> (n -> Bool) | target |
-> Maybe [n] | the shortest path, if it exists |
Breadth-first search, with loop detection
binaryMinSearch :: (Int -> Bool) -> Int -> Int -> Maybe Int Source #
Find the lowest value where the predicate is satisfied within the given bounds.
exponentialMinSearch :: (Int -> Bool) -> Int -> Maybe Int Source #
Find the lowest value where the predicate is satisfied above a given bound.