저는 2 개의 Ints n, x를 허용하는 함수를 가지고 floor (log n/log x)를 계산합니다. 여기서 n과 x는 둘 다 매우 제한되어 Int는 나를 위해 충분합니다.하스켈에서 'floor'함수의 유형 오류
No instance for (RealFrac (a -> b))
arising from a use of `floor' at p5_evenly_divide.hs:20:11-63
Possible fix: add an instance declaration for (RealFrac (a -> b))
In the expression:
floor (log . fromIntegral n/(log . fromIntegral x))
In the definition of `func':
func n x = floor (log . fromIntegral n/(log . fromIntegral x))
가 어떻게이를 통해 얻을 수 있습니다 :
func :: Int -> Int -> Int
func n x = floor (log . fromIntegral n/(log . fromIntegral x))
그러나 여기가 ghci에서 오류가 온다?
난 당신이 두 문제를 설명하는 방법과 문제를 해결하는 방법을 좋아한다. 정말 도움이됩니다. – Chuck
감사합니다. –
RealFrac에서 'floor'가 사용되어야한다는 오류 메시지가 표시되어 잘못된 방향으로 계속 걸었습니다. –