Skip to content

Added tree map#61

Open
IgnatSergeev wants to merge 1 commit intomainfrom
tree-map
Open

Added tree map#61
IgnatSergeev wants to merge 1 commit intomainfrom
tree-map

Conversation

@IgnatSergeev
Copy link
Owner

No description provided.

let rec treeMap func tree =
match tree with
| Node (value, lhs, rhs) -> Node (func value, treeMap func lhs, treeMap func rhs)
| Leaf value -> Leaf (func value)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я бы сказал, что нужны комментарии. Ещё будь я Косарев, я бы сказал, что нужна хвостовая рекурсия, так что treeMap можно расписать в CPS с continuation-ом для левого поддерева, который вызывает continuation для правого. Но это одна из первых домашек, так что пусть будет зачтена.

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

Successfully merging this pull request may close these issues.

2 participants