Skip to content

Instantly share code, notes, and snippets.

@palladin
Created July 17, 2011 20:15
Show Gist options
  • Save palladin/1088013 to your computer and use it in GitHub Desktop.
Save palladin/1088013 to your computer and use it in GitHub Desktop.
A beautiful fixed-point finding function
let rec iterate f value =
seq { yield value;
yield! iterate f (f value) }
let fixedPoint f initial =
iterate f initial
|> Seq.pairwise
|> Seq.pick (fun (first, second) ->
if first = second then Some first else None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment