OCaml: Is there a function with type 'a -> 'a other than the identity function?
问题 This isn't a homework question, by the way. It got brought up in class but my teacher couldn't think of any. Thanks. 回答1: How do you define the identity functions ? If you're only considering the syntax, there are different identity functions, which all have the correct type: let f x = x let f2 x = (fun y -> y) x let f3 x = (fun y -> y) (fun y -> y) x let f4 x = (fun y -> (fun y -> y) y) x let f5 x = (fun y z -> z) x x let f6 x = if false then x else x There are even weirder functions: let f7