在OCaml中,我怎么都可以:
在haskell中就像
f arg@{..} = some code using both arg and its fields
答案 0 :(得分:7)
使用as
。例如:
let f ((a, b) as original) =
if a > b then
(b, a)
else
original
或:
let g = function
| [] -> []
| (x :: _) as l -> x :: l