刚开始学习Haskell。在Haskell中调用函数 - 初学者问题
我有这里面空的源文件:
pe :: (Integral a) => a -> a
pe y = sum [x | x <- [1..y-1], x `mod` 3 == 0 || x `mod` 5 == 0]
现在,如果我GHCI这一点,我可以叫PE,像这样:
*Main> pe 1000
233168
我如何把它从我的源代码中文件?如果我有
pe 1000
它返回一个神秘的错误:
GHC stage restriction: `pe'
is used in a top-level splice or annotation,
and must be imported, not defined locally
In the expression: pe 1000
我需要声明它主要还是什么?
或'main = mapM_(print.pe)[1..1000]'如果您需要为大量的值进行操作。 – alternative 2011-05-28 00:20:18