We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
In Haskell, you can get the correct order of traversal for printing by setting up a Foldable instance in the correct way and then using the toList function. (If you define foldMap instead of foldr, it is much easier to get the order correct.) In my solution, it looks like this:
Swap Nodes
You are viewing a single comment's thread. Return to all comments →
In Haskell, you can get the correct order of traversal for printing by setting up a Foldable instance in the correct way and then using the
toList
function. (If you definefoldMap
instead offoldr
, it is much easier to get the order correct.) In my solution, it looks like this: