Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P55, P56页笔误 #54

Open
hongy19 opened this issue Feb 1, 2020 · 1 comment
Open

P55, P56页笔误 #54

hongy19 opened this issue Feb 1, 2020 · 1 comment

Comments

@hongy19
Copy link

hongy19 commented Feb 1, 2020

P55, P56页有笔误。
P55 "我们用图表来直观地表示这两个函数的区别
(:) --- foldr f z ---> f" -> 此处的foldr应该是 foldl。
P56页相应的foldl 应该为foldr

@youwillbe
Copy link

P55, P56页有笔误。 P55 "我们用图表来直观地表示这两个函数的区别 (:) --- foldr f z ---> f" -> 此处的foldr应该是 foldl。 P56页相应的foldl 应该为foldr

这两个没问题的,只不过 foldl 右边的函数应用的树可能上下颠倒过来更形象一些

foldr f z [1, 2, 3] ≡ 1 `f` (2 `f` (3 `f` z))

 (:)  --- foldr f z --- f
 / \                   / \
1  (:)                1   f
   / \                   / \
  2  (:)                2   f
     / \                   / \
    3  []                 3   z

foldl f z [1, 2, 3] ≡ (z `f` 1) `f` 2) `f` 3

 (:)  --- foldl f z --- z   1
 / \                     \ /
1  (:)                    f   2
   / \                     \ /
  2  (:)                    f   3
     / \                     \ /
    3  []                     f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants