我讀功能不斷:SML不斷執行力度
fun constantly k a = k
但我不知道如何使用它。 我試過這樣:
val a = constantly 10;
stdIn:32.5-32.28 Warning: type vars not generalized because of
value restriction are instantiated to dummy types (X1,X2,...)
val a = fn : ?.X1 -> int * int -> int
它的工作原理是這樣:
val a = constantly 10();
val a : int = 10
但不是這樣的:
val a = constantly 10;
a();
stdIn:36.1-36.5 Error: operator and operand don't agree [tycon mismatch]
operator domain: ?.X1
operand: unit
in expression:
a()
任何人可以幫助我在功能understanting?
謝謝!最終我明白了! –