Skip to content

Instantly share code, notes, and snippets.

@davidgrenier
Created June 2, 2013 19:50
Show Gist options
  • Save davidgrenier/5694694 to your computer and use it in GitHub Desktop.
Save davidgrenier/5694694 to your computer and use it in GitHub Desktop.
Identify a run of consecutive characters.
let rec (|Run|_|) n c =
let rec identicals n = function
| rest when n = 0 -> Some rest
| a :: rest when a = c && n > 0 -> identicals (n - 1) rest
| _ -> None
identicals n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment