【发布时间】:2021-11-01 18:23:41
【问题描述】:
我是 SML 的新手。有人可以解释为什么第四行给我这个错误吗?我完全不知道为什么。
fun plus x y = x + y;
fun twice f x = f ( f ( x));
fun repeat n f x = if n = 0 then x else repeat (n-1) f (f(x));
fun times x y = repeat( x (plus( x y)) x);
- val plus = fn : int -> int -> int
val twice = fn : ('a -> 'a) -> 'a -> 'a
val repeat = fn : int -> ('a -> 'a) -> 'a -> 'a
stdIn:4.25-4.41 Error: operator is not a function [tycon mismatch]
operator: int
in expression:
(x (plus (x y))) x
【问题讨论】:
标签: functional-programming sml smlnj