[Haskell-beginners] define action getInt like getLine

Daniel Fischer daniel.is.fischer at web.de
Tue Feb 2 17:16:01 EST 2010


Am Dienstag 02 Februar 2010 23:06:41 schrieb legajid:
> -- Définition de la fonction de calcul
> f Nothing = -9999
> f (Just x) = 2 * x

That's already in the standard libs:

ghci> :t maybe
maybe :: b -> (a -> b) -> Maybe a -> b
ghci> maybe (-9999) (*2) (Just $ fromEnum 'k')
214


More information about the Beginners mailing list