[Haskell-cafe] separate input calculation output

Thomas Engel thomas.engel1 at gmx.net
Tue Mar 25 04:13:29 EDT 2008


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080325/f356e92a/attachment.bin

More information about the Haskell-Cafe mailing list