shell to run functions

Jens Petersen petersen@redhat.com
12 Sep 2001 16:32:06 +0900


Johansson Mikael <mikael.mj.johansson@volvo.com> writes:

> But when I try to write a program with this function:
> 
> f x 	= x mod 7 == 0 || 
>  	   x mod 10 == 7 || 
>  	   x div 10 mod 10 == 7
> 
> The IO doesn't seem to work
> How do I put programs like this in a IO shell.

Haskell can be confusing at first.

How about:

f :: Integer -> Bool
f x 	= x `mod` 7 == 0 || 
 	   x `mod` 10 == 7 || 
 	   x `div` 10 `mod` 10 == 7

main = do
       putStrLn $ show (f 1)


Hope that helps,

Jens