[Haskell-beginners] maybe this could be improved?
Darrin Thompson
darrinth at gmail.com
Wed Nov 11 11:06:27 EST 2009
On Sat, Nov 7, 2009 at 12:44 PM, Michael Mossey <mpm at alumni.caltech.edu> wrote:
> where case1 = return . fst . M.findMin $ m2
> case2 = return . fst . M.findMax $ m1
> case3 = return $ closest (fst . M.findMax $ m1)
> (fst . M.findMin $ m2)
> closest a b = if abs (a - inPitch) < abs (b - inPitch)
> then a
> else b
>
I'd try writing quickcheck properties for these cases.
That is a really complicated function. It strikes me that a lot of
those cases need less available in their scopes than they have. You
could force that by breaking the cases and closest into individual
functions. Then you could write properties for them. Then you are left
with only one complex function determining which case you need.
Possibly you could return the case directly?
Anyway, that's not as helpful as telling you that you just reinvented
a 4 and a half gainer comonad or whatever but if you start cutting
this thing up you might notice a structure you already know.
--
Darrin
More information about the Beginners
mailing list