
Hello! I have problems running functions in a haskell program being able to give input and get output via the keyboard. I have a glasgow compiler and have successfully made a compiled and runned a program wich read a char and writes it back to screen. main :: IO () main = do c <- getChar putChar c 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. Thanks in advance. Mikael Johansson Volvo Aero Corporation Military Engines Trollhättan Dept. 7164MJ SE-461 81 Trollhättan, Sweden phone +46 520 940 61 e-mail: mikael.mj.johansson@volvo.com

Johansson Mikael
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
participants (2)
-
Jens Petersen
-
Johansson Mikael