小编And*_*ith的帖子

Haskell用匿名函数折叠

我有一个Haskell基础知识的问题:折叠+匿名函数

我正在开发一个bin2dec程序foldl.
解决方案如下所示:

bin2dec :: String -> Int
bin2dec = foldl (\x y -> if y=='1' then x*2 + 1 else x*2) 0
Run Code Online (Sandbox Code Playgroud)

我理解foldl/ 的基本思想,foldr但我无法理解参数的含义x y.

haskell anonymous-function fold

3
推荐指数
1
解决办法
4285
查看次数

标签 统计

anonymous-function ×1

fold ×1

haskell ×1