|
 |
Slime wrote:
> > find :: (Ord y) => (x -> y) -> y -> IArray x -> (Int,Int) -> Maybe x
> > find field target array (base,size)
> > | size < 0 = error "invalid subrange size"
> > | size == 0 = Nothing
> > | size == 1 = if field (array ! base) == target then Just (array !
> > base) else Nothing
> > | otherwise =
> > let size2 = size `div` 2
> > in find field target array (base, size2) `mappend` find field target
> > array (base + size2, size - size2)
>
> I don't know Haskell, but my best guess at understanding this code looks
> like you're always recursing into both sides, without actually doing the
> comparison of the center element to the target element.
Oh... my god... >_<
I blame Warp. I was so busy making sure that there's no off-by-one
errors that I totally forgot to actually, you know, IMPLEMENT THE RIGHT
ALGORITHM!
Post a reply to this message
|
 |