Tree traversal: Difference between revisions
Content deleted Content added
m →JS ES6 |
m →JS ES6 |
||
Line 5,909:
const preorder = x =>
xs => [x, ...xs.flat()];
// inorder :: a -> [[a]] -> [a]
Line 5,915 ⟶ 5,916:
[...xs[0], x, ...xs.slice(1).flat()]
) : [x];
// postorder :: a -> [[a]] -> [a]
const postorder = x =>
xs => [...xs.flat(), x];
// levelOrder :: Tree a -> [a]
|