Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.71 KB | None | 0 0
  1. module SpaceAge
  2.  
  3. type Planet = Earth | Mercury | Venus | Mars | Jupiter | Saturn | Uranus | Neptune
  4.  
  5. let getPlanetFactor (planet: Planet) =
  6.     let earthSeconds = 31557600.0 in
  7.         match planet with
  8.         | Earth -> earthSeconds
  9.         | Mercury -> earthSeconds * 0.2408467
  10.         | Venus -> earthSeconds * 0.61519726
  11.         | Mars -> earthSeconds * 1.8808158
  12.         | Jupiter -> earthSeconds * 11.862615
  13.         | Saturn -> earthSeconds * 29.447498
  14.         | Uranus -> earthSeconds * 84.016846
  15.         | Neptune -> earthSeconds * 164.79132
  16.  
  17. let age (planet: Planet) (seconds: int64): float =
  18.     let seconds = seconds |> float in
  19.         System.Math.Round (seconds / getPlanetFactor planet, 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement