Created
October 17, 2015 14:06
-
-
Save derekmorr/e583b7aa42f40b8011e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
let GoldenTuples numbers = | |
let GoldenRatio = (1.0 + Math.Sqrt(5.0)) / 2.0 | |
seq { | |
for n in numbers do | |
yield (n, (float n) * GoldenRatio) | |
} | |
let rec GetNumber numbers = | |
printf "Enter the number: " | |
let k = Console.ReadLine() | |
let couldparse, num = Int32.TryParse k | |
if couldparse then | |
num :: numbers | |
else | |
printfn "Error parsing input." | |
GetNumber numbers | |
let rec RunLoop numbers = | |
printf "Do you want to add another number (y/n)? " | |
let k = Console.ReadLine() | |
if k.ToLower() = "y" then | |
let newNumbers = GetNumber numbers | |
RunLoop newNumbers | |
else | |
List.rev numbers | |
[<EntryPoint>] | |
let main argv = | |
let initialNum = GetNumber [] | |
let rawNumbers = RunLoop initialNum | |
let goldenNumbers = GoldenTuples rawNumbers | |
for n in goldenNumbers do printfn "%A" n | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment