与元素haskell功能功能的非排量模式

发布于 2025-02-12 11:54:37 字数 1488 浏览 0 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一个人的旅程 2025-02-19 11:54:37

因为regiuleishon不是reguleishon,所以reguleishon(false,x)...是一种新功能声明,导致代码具有2个不同函数两者都没有详尽的模式。

正确命名第二种模式:

regiuleishon :: (Bool, Integer) -> Integer
regiuleishon (True, _) = 0
regiuleishon (False, x) | x >= 0 = 1
                        | otherwise = -1

Because regiuleishon is not reguleishon, so reguleishon (False, x) ... is a new function declaration leading to the code having 2 different functions neither of which have exhaustive patterns.

Name the second pattern correctly:

regiuleishon :: (Bool, Integer) -> Integer
regiuleishon (True, _) = 0
regiuleishon (False, x) | x >= 0 = 1
                        | otherwise = -1
傲性难收 2025-02-19 11:54:37

您有一个错别字:第二行说regiuleishon,但第三行说geguleishon - 缺少i g 。

因此,对于编译器而言,看起来您已经完成了定义名为regiuleishon的函数,然后移动到定义一个完全不同的函数,名为reguleishon。第一个功能仅涵盖true案例,因此模式匹配不完整。第二个功能仅涵盖false案例,因此其匹配也不完整。

You have a typo: the second line says regiuleishon, but the third line says reguleishon - missing an i after g.

So to the compiler, it looks like you're done defining the function named regiuleishon and moved on to defining a totally different function named reguleishon. The first function only covers the True case, so the pattern match is incomplete. And the second function only covers the False case, so its match is incomplete as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文