/ Published in: Haskell

Improved version, using lenses instead of the dangerous (!!) operator for list access.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
module BinarySearch where import Control.Lens import Data.Maybe a = [6, 13, 14, 25, 33, 43, 51, 53, 64, 72, 84, 93, 95, 96, 97] bsearch _ [] = Nothing bsearch key xs where val = xs ^? ix mid
Comments
