On 5/30/06, Thorkil Naur <[EMAIL PROTECTED]> wrote:
Hello,Both my Hugs and my GHCi report a type error when presented with this. A possible repaired version looks like this: calc :: String -> Float calc = g . foldl f [] . words where f (x:y:zs) "+" = y+x:zs f (x:y:zs) "-" = y-x:zs f (x:y:zs) "*" = y*x:zs f (x:y:zs) "/" = y/x:zs f xs y = read y : xs g [r] = r Not as small, but still quite nice.
..or you could just have it return [Float], maybe that's the intention (you could do several computations). Or throw in a "head" in there instead of defining a new function. /S -- Sebastian Sylvan +46(0)736-818655 UIN: 44640862 _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
