Skip to content

Instantly share code, notes, and snippets.

@PollRobots
Created January 18, 2013 05:36
Show Gist options
  • Save PollRobots/4562581 to your computer and use it in GitHub Desktop.
Save PollRobots/4562581 to your computer and use it in GitHub Desktop.
| Sequence x ->
let rec parseList lst off =
seq {
if List.isEmpty lst then ()
else
match parse off <| List.head lst with
| (Unmatched, _) as y -> yield y
| (y, z) -> yield (y, z)
yield! parseList (List.tail lst) z
}
let s = List.ofSeq <| parseList x offset
if List.exists (function | (Unmatched, _) -> true | _ -> false) s then (Unmatched, offset)
else (Production <| List.map fst s, snd <| List.maxBy snd s)
| Choice x ->
let rec parseList lst =
if List.isEmpty lst then (Unmatched, offset)
else
match parse offset <| List.head lst with
| (Unmatched, _) -> parseList <| List.tail lst
| y -> y
parseList x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment