nic*_*las 4 ocaml pattern-matching
在OCaml中,我怎样才能:
在haskell它就像
f arg@{..} = some code using both arg and its fields
Run Code Online (Sandbox Code Playgroud)
使用as
.例如:
let f ((a, b) as original) =
if a > b then
(b, a)
else
original
Run Code Online (Sandbox Code Playgroud)
要么:
let g = function
| [] -> []
| (x :: _) as l -> x :: l
Run Code Online (Sandbox Code Playgroud)