【发布时间】:2021-07-11 07:02:36
【问题描述】:
我是 Haskell 语言的新手,我想在 where binding 中使用 guard,但出现错误: 不在范围内:`x' 失败,已加载模块:无。
describelist'' :: [a] ->String
describelist'' xs = "the list is : " ++ what xs
where what xs
| xs == "" = "empty list "
| xs ==[x] = "singleton"
| otherwise = "list more than or equal two elements"
我认为我的代码是正确的,但总是出现错误,
【问题讨论】:
-
xs == [x]没有意义(作为守卫),因为您没有定义x,这是一种模式。
标签: haskell