你好,我使用 sublime text 3 和我的 cmd shell 和 ghci。我在 st3 中编写了以下函数:
testing :: Int -> Bool
testing 0 = True
testing 1 = False
testing n = testing(n mod 2)
Run Code Online (Sandbox Code Playgroud)
我知道 haskell 提供了一个 even 函数,但我们必须编写我们自己的 even 函数,所以我想出了这个。当我将文件加载到 ghci 中时:
:cd <pathtofile>
:l myfile.hs
Run Code Online (Sandbox Code Playgroud)
并尝试执行我的功能
testing 10
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Variable not in scope: testing :: t0 -> t
Run Code Online (Sandbox Code Playgroud)
我可能应该提到 testing :: Int -> Bool 使用斐波那契函数共享文件,但这不应该是问题吧?任何帮助表示赞赏!
您好,我试图从适用于我的函数的列表中删除元素,例如: removeBy 甚至 [1..10] ?[1,3,5,7,9] 或 removeBy (=='a' ) ['b' , 'a' ,'c' ] ?“公元前”
使用高阶函数,如 map、foldl、foldr 和 filter 我所做的是
removeBy :: (a -> Bool) -> [a] -> [b]
removeBy function list = map function list
Run Code Online (Sandbox Code Playgroud)
当我尝试运行示例 1 时,即使我得到
Variable not in scope: removeBy :: (a0 -> Bool) -> [a1] -> t
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我吗?