小编rea*_*ado的帖子

编写高阶函数来捕获常见模式haskell

f1 [] = 1
f1 (x:xs) = x * f1 xs

f2 [] = 0
f2 (x:xs) = 1 + f2 xs

f3 [] = 0
f3 (x:xs) = x + f3 xs

f4 [] = []
f4 (x:xs) = x ++ f4 xs
Run Code Online (Sandbox Code Playgroud)

这些都有一个共同的行为,我究竟如何识别模式并编写高阶函数来捕获它?

haskell functional-programming

15
推荐指数
2
解决办法
591
查看次数

标签 统计

functional-programming ×1

haskell ×1