Transforming OCaml code to F# -


i'm transforming ocaml code f# having problem ocaml let...and... exists in f# using recursive function. have given ocaml code:

let matches s = let chars = explode s in fun c -> mem c chars let space = matches " \t\n\r" , punctuiation = matches "() [] {}," , symbolic = matches "~'!@#$%^&*-+=|\\:;<>.?/" , numeric = matches "0123456789" , alphanumeric = matches "abcdefghijklmopqrstuvwxyz_'abcdefghijklmnopqrstuvwxyz" 

which want use in these 2 methods:

let rec lexwhile prop inp = match inp 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 []->[] |c::cs ->let prop = if alphanumeric(c) alphanumeric                     else if symbolic(c) symbolic                     else fun c ->false in                     let toktl,rest = lexwhile prop cs in                     (c+toktl)::lex rest 

has idea how have change can use it?

it looks trying translate "handbook of practical logic , automated reasoning".

did see: an f# version of book code available! eric taucher, jack pappas , anh-dung phan.

you need @ intro.fs

// pg. 17  // ------------------------------------------------------------------------- //  // lexical analysis.                                                         //  // ------------------------------------------------------------------------- //    let matches s =       let chars =           explode s       fun c -> mem c chars   let space = matches " \t\n\r"    let punctuation = matches "()[]{},"   let symbolic = matches "~`!@#$%^&*-+=|\\:;<>.?/"   let numeric = matches "0123456789"   let alphanumeric = matches "abcdefghijklmnopqrstuvwxyz_'abcdefghijklmnopqrstuvwxyz0123456789"   let rec lexwhile prop inp =      match inp      | c :: cs when prop c ->          let tok, rest = lexwhile prop cs          c + tok, rest      | _ -> "", inp   let rec lex inp =      match snd <| lexwhile space inp      | [] -> []      | c :: cs ->          let prop =              if alphanumeric c alphanumeric              else if symbolic c symbolic              else fun c -> false          let toktl, rest = lexwhile prop cs          (c + toktl) :: lex rest 

i asked many questions here while working on translation , prefixed them converting ocaml f#:. if in comments see how 3 of came work on project.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -