Skip to content

Instantly share code, notes, and snippets.

@OakRaven
Created October 18, 2015 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OakRaven/ab26f6c42598df60cbdc to your computer and use it in GitHub Desktop.
Save OakRaven/ab26f6c42598df60cbdc to your computer and use it in GitHub Desktop.
Submission of Module 3 - Assignment
open System
let GoldenRatio = (1.0 + Math.Sqrt(5.0)) / 2.0
let GetValues =
Console.Write("How many numbers would you like to enter? ")
let count = Console.ReadLine();
let count = int count
let values = [
if count > 0 then
for i = 1 to count do
Console.Write(String.Format("Enter value #{0}: ", i));
let value = Console.ReadLine()
yield (float value) ]
values
let CalculateGoldenRatio value =
value * GoldenRatio
let GetGoldenRatioTuples (values : list<float>) =
[
for i in values do
yield (i, (CalculateGoldenRatio i)) ]
[<EntryPoint>]
let main argv =
let values = GetValues
let tuples = GetGoldenRatioTuples values
for i = 0 to tuples.Length - 1 do
let x, y = tuples.Item(i)
Console.WriteLine(String.Format("{0}: {1}", x, y))
Console.ReadKey()
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment