Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 9th, 2012  |  syntax: F#  |  size: 0.31 KB  |  views: 422  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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)