我正在将一些OCaml代码转换为具有OCaml问题的F#,该问题let...and...仅通过使用递归函数存在于F#中.我有给定的OCaml代码:
let matches s = let chars = explode s in fun c -> mem c chars
let space = matches " \t\n\r"
and punctuiation = matches "() [] {},"
and symbolic = matches "~'!@#$%^&*-+=|\\:;<>.?/"
and numeric = matches "0123456789"
and alphanumeric = matches "abcdefghijklmopqrstuvwxyz_'ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Run Code Online (Sandbox Code Playgroud)
我想在这两种方法中使用它:
let rec lexwhile prop inp = match inp with
c::cs when prop c -> let tok,rest = lexwhile prop cs in c+tok,rest
|_->"",inp
let rec lex inp =
match snd(lexwhile space inp)with …Run Code Online (Sandbox Code Playgroud)