Haskell でプログラミングしていますが、次のコードに問題があります。
exactRootList :: Int -> Int -> [Int]
exactRootList ini end =
[x | x<-[ini .. end], (floor (sqrt x)) == (ceiling (sqrt x))]
次に、実行すると:
> hugs myprogram.hs
私は得る
Error Instances of (Floating Int, RealFrac Int) required for definition of exactRootList
このエラーがわかりません。
私のプログラムは、間隔 [a, b] で、正確なルートが 4 または 9 である数値のリストを表示する必要があります。ここで、a と b は関数の 2 つのパラメーターです。例:
exactRootList 1 10
返さなければならない
1 4 9
1 と 10 の間で 1、4、9 だけが完全な根を持つからです。
ご挨拶!