Advanced Functional Prog.

back - up - cont


Parsing expressions

In the case of regular expressions, another interesting operator is the alternative/choice:

let alt p1 p2 (s:string) = 
  match p1 s with
  | [r] -> [r]
  | _   -> p2 s;;

let (||) = alt;;

((sym 'H') || (sym 'h')) "hello";;

4 - 18