相关疑难解决方法(0)

在Haskell中,为什么我必须在此代码中使用美元符号?

我还在尝试破解这段代码:

import Data.Char
groupsOf _ [] = []
groupsOf n xs = 
    take n xs : groupsOf n ( tail xs )

problem_8 x = maximum . map product . groupsOf 5 $ x
main = do t <- readFile "p8.log" 
      let digits = map digitToInt $concat $ lines t
      print $ problem_8 digits
Run Code Online (Sandbox Code Playgroud)

problem_8 x = maximum . map product . groupsOf 5 $ x 为什么不能只是被groupsOf 5×?是因为x以后会扩展到其他一些表达式(这里它将是:) digits = map digitToInt $concat $ lines t?这是所谓的懒惰(x现在不会扩展,但也许以后)?

haskell

7
推荐指数
3
解决办法
2447
查看次数

标签 统计

haskell ×1