Skip to content

Instantly share code, notes, and snippets.

@wklm wklm/checked.fs
Last active Nov 5, 2017

What would you like to do?
F# Checked arithmetic operator overloading example
open System
let (+) x y = Checked.(+) x y
let number = Random().Next()
let rec guess (lower, upper) =
let x = (lower + upper) / 2
if number > x then
guess (x, upper)
elif number < x then
guess (lower, x)
else x
let x = guess(Int32.MinValue, Int32.MaxValue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.