[Haskell-cafe] haltavista - look for functions by example

Roel van Dijk vandijk.roel at gmail.com
Sun Sep 19 13:46:54 EDT 2010


In my haste to reply I made an error in my 'newby' multiplication
function. Pesky negative numbers...

  intMul ∷ Integer → Integer → Integer
  intMul x n | n <  0 = -(intMul x $ abs n)
             | n == 0 = 0
             | n >  0 = x + intMul x (n - 1)

I do wonder what happens when haltavista encounters a function that
diverges. Like my original intMul applied to a negative number:
"intMul 2 (-1)".


More information about the Haskell-Cafe mailing list