Fixed a bug in binary-search that caused an infinite loop.
binary-search now takes an optional mapping function.