Skip to content

Instantly share code, notes, and snippets.

@rtipton
Created April 15, 2010 10:15
Show Gist options
  • Save rtipton/366942 to your computer and use it in GitHub Desktop.
Save rtipton/366942 to your computer and use it in GitHub Desktop.
F# -- Calculate Max Heartrate based on age input
// Calculates the maximum heartrate based on the age input by the user
(* Strings in F# are by default, immutable. If you want the string to change
in any way [ie, assigning values, concantination, etc] you must make the
variables mutable. *)
open System
let main() =
let mutable maxHR = 0
let mutable entries = 0
let mutable age = String.Empty
while entries < 5 do
Console.Write("Enter your age: ")
entries <- entries + 1
age <- Console.ReadLine()
maxHR <- 220 - Int32.Parse(age)
Console.WriteLine("Your Max Heartrate is " + maxHR.ToString())
Console.ReadKey(true) |> ignore
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment