[Top] [All Lists]

[Haskell-cafe] separate input calculation output

Subject: [Haskell-cafe] separate input calculation output
From: Thomas Engel
Date: Tue, 25 Mar 2008 09:13:29 +0100

I'm new to haskell and want to write a small program for some  winder 
calcucations. I want to input 10-15 values and based on this input
doing some calculations. After this calculations I want to print out the

My problem is: How can I get the input values into the calculations and back
the result to the output.

In an other language I would use global variables for this. So what should I
use in haskell?

An other point is that I want to separate the input from the calculations and
the output.

How can I achieve this with haskell? Modules? Data types?

See some pseudo code below.

inputvalues  ::  IO()
inputvalues = do  hSetBuffering stdout NoBuffering
              putStr "Berechnung Bremsgenerator \n\n"
              ve <- readNum  "Bitte Maschinengeschwindigkeit (m/min) angeben: "
              de <- readNum "Bitte Durchmesser der vollen Rolle eingeben (mm): "
              dewalze <- readNum "Bitte Durchmesser der Walze eingeben (mm): "
              dewand <- readNum "Bitte Wandstaerke der Walze eingeben (mm): "

              and so on ..............

readNum :: String -> IO Float
readNum text  = do putStrLn text

-- calculations

nvr :: Float-> Float-> Float
nvr ve de     =  ve / de /pi *1000

pzugmin :: Float-> Float-> Float->Float
pzugmin ve femin be = 1.666 * ve * femin * be * 0.00000001

pzugmax :: Float-> Float-> Float->Float
pzugmax ve femax be = 1.666 * ve * femax * be * 0.00000001

and so on ..............

outputvalues = do  putStr "\n\nErgebnisse Bremsgenerator \n\n"
                   putStr "Drehzahl leere Trommel: "
                   putStr " U/min \n"
                   putStr "Drehzahl volle Trommel: "
                   putStr " U/min \n"

                  and so on ......................

Thanks Thomas

Haskell-Cafe mailing list
<Prev in Thread] Current Thread [Next in Thread>