小编Dad*_*dum的帖子

将OCaml代码转换为F#

我正在将一些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)

f# ocaml

5
推荐指数
1
解决办法
175
查看次数

标签 统计

f# ×1

ocaml ×1