Advertisement
Guest User

Jednoducha kalkulacka v fsharp

a guest
Jan 14th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.68 KB | None | 0 0
  1. open System
  2.  
  3. let vypocti (x:double) (y:double) =
  4.     seq {yield "scitani", x+y;
  5.          yield "odcitani", x-y;
  6.          yield "nasobeni", x*y;
  7.          yield "deleni", x/y}
  8.  
  9. [<EntryPoint>]
  10. let main argv =
  11.     let mutable again = true
  12.     while again do
  13.         printfn "Zadej dvě čísla po sobě:"
  14.         let ok1, value1 = Double.TryParse(Console.ReadLine())
  15.         let ok2, value2 = Double.TryParse(Console.ReadLine())
  16.         if ok1 && ok2 then
  17.             Seq.iter (fun (a,b) -> printfn "%s %f" a b) (vypocti value1 value2)
  18.             again <- false
  19.             Console.ReadKey() |> ignore
  20.         else printfn "Zkus to znovu!"
  21.    
  22.     0 // return an integer exit code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement