I’m at the moment trying to make a very simple app that will greet depending on the time of the day. My code is:
open System
let read() = Console.Read()
let readLine() = Console.ReadLine()
let clockMsg min max todo =
if (DateTime.Now.Hour > min) && (DateTime.Now.Hour < max) then todo
let name = readLine()
clockMsg 0 8 <| printfn "Go to bed, %s!" name
clockMsg 8 12 <| printfn "Good morning, %s!" name
clockMsg 12 18 <| printfn "Good afternoon, %s!" name
read() |> ignore
Now is my question, how can only ONE of the function calls be valid, but all three will no matter what, print their messages?
Agree with BrokenGlass. What you probably want to do is:
and this change in
clockMsg: