SHARE
TWEET

Untitled

a guest Feb 9th, 2012 494 Never
  1. let rec loop(start, last) =
  2.     let mid = (start + last) / 2
  3.     printfn "Is your number %d (H - Too High/L - Too Low/=)?" mid
  4.     let answer = System.Console.ReadLine()
  5.     match answer with
  6.     | "H" -> loop(start, mid)
  7.     | "L" -> loop(mid+1, last)
  8.     | "=" -> printfn "Your number is %d!" mid
  9.  
  10. loop(0, 100)
RAW Paste Data
Top