小编jks*_*end的帖子

Haskell ghci变量不在范围内

你好,我使用 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 使用斐波那契函数共享文件,但这不应该是问题吧?任何帮助表示赞赏!

haskell ghci sublimetext3

2
推荐指数
1
解决办法
751
查看次数

删除列表中的元素(与过滤相反)

您好,我试图从适用于我的函数的列表中删除元素,例如: 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)

任何人都可以帮助我吗?

haskell

0
推荐指数
1
解决办法
76
查看次数

标签 统计

haskell ×2

ghci ×1

sublimetext3 ×1