Hallo,
einmal der Code:
module Task29 where
import System.IO
main :: IO ()
main = do
hSetBuffering stdout NoBuffering -- needed depending on your operating system and settings
putStrLn "Bitte gebe die erste Zahl ein:"
x1 <- readLn
putStrLn "Zweite"
x2 <- readLn
let sum = x1 + x2
print ("Die Summe ist:" ++ show(sum))
result <- while (x1,1) (\x -> x/=0) (\(x,count) -> do putStrLn "Bitte gebe die erste Zahl an"
x1 <- readLn
putStrLn "Zweite"
x2 <- readLn
let sum = x1 + x2
print ("Die Summe ist:" ++ show(sum))
return (x1,(count+1)))
print ("Anzahl additionen:" ++ show(snd(result)))
while :: a -> (a -> Bool) -> (a -> IO a) -> IO a
while a p body = loop a
where loop x = if p x then do x'<- body x
loop x'
else return x
Und einmal die beschwerde:
das Gleich kommt bei let sum = x1 + x2, bei show und bei der 1 im Tupel (x1,1), und bei /=0.
Ich verstehe nicht was der mir damit sagen will und wie ich das lösen kann.
Schonmal danke:))