1
나는 다음과 같은 코드가 있습니다기능 성분 인수에 오류가
let add n x = x + n
let times n x = x * n
let addTimes = add 5 >> times 5
addTimes 4
을하고이 아무 문제없이 작동합니다. 나는이
let add n x = x + n
let times n x = x * n
let addTimes = add >> times
addTimes 4
처럼 변경할 때하지만 난 컴파일 오류
error FS0071: Type constraint mismatch when applying the default type '(int -> int)' for a type inference variable. Expecting a type supporting the operator '*' but given a function type. You may be missing an argument to a function. Consider adding further type constraints
왜
있어?
함수 구성은 기본적으로 f (g (x))이지만 g (x)는 단일 값을 반환하는 반면 f는 2 개의 인수를 취합니다 - 어떻게 구성이 작동 할 것으로 예상됩니까? –
제 문제는 컴포지션이 어떻게 작동하는지 모르겠다는 것입니다. 너무 유선이에요. –