@@ -0,0 +1,3 @@ | |||
.fake | |||
.ionide |
@@ -22,7 +22,6 @@ let alternatingSum n = | |||
printInt (alternatingSum 100) | |||
// Now we can factor out the commonality and re-write these functions like so: | |||
let iterAct ini act n = | |||
[1..n] |> List.fold act ini | |||
@@ -31,4 +30,3 @@ printInt (product2 10) | |||
let sumOfOdds2 = iterAct 0 (fun x y -> if y % 2 = 0 then x else x + y) | |||
printInt (sumOfOdds2 10) | |||
@@ -0,0 +1,18 @@ | |||
open System | |||
let r = Random() | |||
let secretNum = r.Next(1, 100) | |||
printfn "Secret Num is between 1-100" | |||
let mutable found = false | |||
while (not found) do | |||
printfn "Enter a guess:" | |||
let guess_s = Console.ReadLine() | |||
let guess = Convert.ToInt32(guess_s) | |||
match guess with | |||
| guess when secretNum = guess -> | |||
printfn "You guessed correctly!" | |||
found <- true | |||
| guess when guess > secretNum -> | |||
printfn "Lower" | |||
| _ -> | |||
printfn "Higher" |