Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
labelsTree' numberNodes
-----------------------------------------------------------------
labelsTree' (Node 1 [Node 2 [Node 4 []], Node 5 []])
-----------------------------------------------------------------
foldtree' (:) (++) [] (Node 1 [Node 2 [Node 4 []], Node 5 []])
-----------------------------------------------------------------
foldnode' (:) (++) [] (Node 1 [Node 2 [Node 4 []], Node 5 []])
-----------------------------------------------------------------
(+) 1 (foldnodes' (:) (++) [] [Node 2 [Node 4 []], Node 5 []])
-----------------------------------------------------------------
(:) 1 (
(++) (foldnode' (:) (++) [] (Node 2 [Node 4 []))
(foldnodes' (:) (++) [] [Node 5 []]))
-----------------------------------------------------------------
(:) 1 (
(++) (foldnode' (:) (++) [] (Node 2 [Node 4 []))
((++) (foldnode' (:) (++) [] (Node 5 []))
(foldnodes' (:) (++) [] [])))
-----------------------------------------------------------------
(:) 1 (
(++) ((:) 2
(foldnodes' (:) (++) [] [Node 4 []))
((++) (foldnode' (:) (++) [] (Node 5 []))
(foldnodes' (:) (++) [] [])))
-----------------------------------------------------------------
(:) 1 (
(++) ((:) 2
(foldnodes' (:) (++) [] [Node 4 []))
((++) (foldnode' (:) (++) [] (Node 5 []))
[]))
-----------------------------------------------------------------
(:) 1 (
(++) ((:) 2
((++) (foldnode' (:) (++) [] (Node 4 []))
(foldnodes' (:) (++) [] [])))
((++) (foldnode' (:) (++) [] (Node 5 []))
[]))
-----------------------------------------------------------------
(:) 1 (
(++) ((:) 2
((++) (foldnode' (:) (++) [] (Node 4 []))
[]))
((++) (foldnode' (:) (++) [] (Node 5 []))
[]))
-----------------------------------------------------------------
(:) 1 (
(++) ((:) 2
((++) (foldnode' (:) (++) [] (Node 4 []))
[]))
((++) ((:) 5 (foldnodes []))
[]))
-----------------------------------------------------------------
(+) 1 (
(++) ((:) 2
((++) (foldnode' (:) (++) [] (Node 4 []))
[]))
((++) ((:) 5 [])
[]))
-----------------------------------------------------------------
(:) 1 (
(++) ((:) 2
((++) ((:) 4 (foldnodes' (:) (++) [] []))
[]))
((++) ((:) 5 [])
[]))
-----------------------------------------------------------------
(:) 1 (
(++) ((:) 2
((++) ((:) 4 [])
[]))
((++) ((:) 5 [])
[]))
-----------------------------------------------------------------
(:) 1 (
(++) ((:) 2
((++) [4]
[]))
((++) ((:) 5 [])
[]))
-----------------------------------------------------------------
(:) 1 (
(++) ((:) 2
((++) [4]
[]))
((++) [5]
[]))
-----------------------------------------------------------------
(:) 1 (
(++) ((:) 2
[4])
((++) [5]
[]))
-----------------------------------------------------------------
(:) 1 (
(++) [2, 4]
((++) [5]
[]))
-----------------------------------------------------------------
(:) 1 (
(++) [2, 4]
[5])
-----------------------------------------------------------------
(:) 1
[2, 4, 5]
-----------------------------------------------------------------
[1, 2, 4, 5]
sumTree' numberNodes
-----------------------------------------------------------------
sumTree' (Node 1 [Node 2 [Node 4 []], Node 5 []])
-----------------------------------------------------------------
foldtree' (+) (+) 0 (Node 1 [Node 2 [Node 4 []], Node 5 []])
-----------------------------------------------------------------
foldnode' (+) (+) 0 (Node 1 [Node 2 [Node 4 []], Node 5 []])
-----------------------------------------------------------------
(+) 1 (foldnodes' (+) (+) 0 [Node 2 [Node 4 []], Node 5 []])
-----------------------------------------------------------------
(+) 1 (
(+) (foldnode' (+) (+) 0 (Node 2 [Node 4 []))
(foldnodes' (+) (+) 0 [Node 5 []]))
-----------------------------------------------------------------
(+) 1 (
(+) (foldnode' (+) (+) 0 (Node 2 [Node 4 []))
((+) (foldnode' (+) (+) 0 (Node 5 []))
(foldnodes' (+) (+) 0 [])))
-----------------------------------------------------------------
(+) 1 (
(+) ((+) 2
(foldnodes' (+) (+) 0 [Node 4 []))
((+) (foldnode' (+) (+) 0 (Node 5 []))
(foldnodes' (+) (+) 0 [])))
-----------------------------------------------------------------
(+) 1 (
(+) ((+) 2
(foldnodes' (+) (+) 0 [Node 4 []))
((+) (foldnode' (+) (+) 0 (Node 5 []))
0))
-----------------------------------------------------------------
(+) 1 (
(+) ((+) 2
((+) (foldnode' (+) (+) 0 (Node 4 []))
(foldnodes' (+) (+) 0 [])))
((+) (foldnode' (+) (+) 0 (Node 5 []))
0))
-----------------------------------------------------------------
(+) 1 (
(+) ((+) 2
((+) (foldnode' (+) (+) 0 (Node 4 []))
0))
((+) (foldnode' (+) (+) 0 (Node 5 []))
0))
-----------------------------------------------------------------
(+) 1 (
(+) ((+) 2
((+) (foldnode' (+) (+) 0 (Node 4 []))
0))
((+) ((+) 5 (foldnodes []))
0))
-----------------------------------------------------------------
(+) 1 (
(+) ((+) 2
((+) (foldnode' (+) (+) 0 (Node 4 []))
0))
((+) ((+) 5 0)
0))
-----------------------------------------------------------------
(+) 1 (
(+) ((+) 2
((+) ((+) 4 (foldnodes' (+) (+) 0 []))
0))
((+) ((+) 5 0)
0))
-----------------------------------------------------------------
(+) 1 (
(+) ((+) 2
((+) ((+) 4 0)
0))
((+) ((+) 5 0)
0))
-----------------------------------------------------------------
(+) 1 (
(+) ((+) 2
((+) 4
0))
((+) ((+) 5 0)
0))
-----------------------------------------------------------------
(+) 1 (
(+) ((+) 2
4)
((+) ((+) 5 0)
0))
-----------------------------------------------------------------
(+) 1 (
(+) 6
((+) ((+) 5 0)
0))
-----------------------------------------------------------------
(+) 1 (
(+) 6
((+) 5
0))
-----------------------------------------------------------------
(+) 1 (
(+) 6
5)
-----------------------------------------------------------------
(+) 1 11
-----------------------------------------------------------------
12
@ryanivandsouza

This comment has been minimized.

Copy link
Owner Author

@ryanivandsouza ryanivandsouza commented Dec 24, 2020

image

@ryanivandsouza

This comment has been minimized.

Copy link
Owner Author

@ryanivandsouza ryanivandsouza commented Dec 24, 2020

image

@ryanivandsouza

This comment has been minimized.

Copy link
Owner Author

@ryanivandsouza ryanivandsouza commented Dec 24, 2020

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment