简体   繁体   English

Haskell清单理解

[英]Haskell List Comprehension

I get the error "Not in scope: x" when doing as follows... 当执行以下操作时,出现错误“不在范围内:x” ...

blanks :: Sudoku -> [Pos]
blanks (Sudoku su) = [ fst x | x <- posSud | isBlank (snd x) ]
    where
        isBlank Nothing = True
        isBlank _       = False
        posSud          = zip ixPos (concat su)
        ixPos           = zip ixRows ixCols
        ixCols          = concat (replicate 9 [0..8])
        ixRows          = [floor (x / 9) | x <- [0..81]]

however, if I remove the guard of the 2:nd line GHCI compiles without giving me any errors. 但是,如果我删除第二行的保护,GHCI编译时不会给我任何错误。

Can you help me understand what I'm doing wrong? 您能帮我了解我在做什么错吗?

try [ fst x | x <- posSud , isBlank (snd x) ] 尝试[ fst x | x <- posSud , isBlank (snd x) ] [ fst x | x <- posSud , isBlank (snd x) ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM