为什么一个参数Ocaml函数适用于两个参数

时间:2016-05-31 12:16:07

标签: function parameters arguments ocaml

我无法理解为什么以下函数适用于2个参数,即使我们用一个参数声明它:

let rec removeFromList e = function
   h :: t -> if h=e then h 
             else h :: removeFromList e t
   | _ -> [];;

removeFromList 1 [1;2;3];;

1 个答案:

答案 0 :(得分:4)

你用两个参数声明它。语法:

let f x = match x with

可以看作是

的捷径
let rec removeFromList e lst = match lst with
  h :: t -> if h=e then h else h :: removeFromList e 

所以,你的定义实际上是:

    guard let toViewController: UIViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey) else { return }
    let toFrame = transitionContext.finalFrameForViewController(toViewController)