binsearch::[Int]->Int->Bool
binsearch [x] y
| x == y = True
| otherwise = False
binsearch xs y =
if y == xs !! ( (length xs ) `div` 2 )
then True
else if y < xs !! ( (length xs ) `div` 2 )
then binsearch (take ( (length xs ) `div` 2) xs) y
else binsearch ( drop ( (length xs ) `div` 2) xs) y
二分查找,布布扣,bubuko.com
二分查找
原文:http://blog.csdn.net/wshcdr/article/details/22278197