/ Published in: Haskell
Not the best binary search implementation -- it really should return a Maybe, Nothing if value not found and Just value if found -- but it was a quick experiment for an evening, and it was cool to see how easily it translated from Java to Haskell.
Expand |
Embed | Plain Text
module BinarySearch where a = [6, 13, 14, 25, 33, 43, 51, 53, 64, 72, 84, 93, 95, 96, 97] bsearch _ [] = -1 bsearch key xs | otherwise = val where val = xs !! mid
You need to login to post a comment.
