Skip to content

Instantly share code, notes, and snippets.

@evgenii-malov
Created January 18, 2021 21:48
Show Gist options
  • Select an option

  • Save evgenii-malov/555386ad33c5fb0bcbd429e3e35ba36e to your computer and use it in GitHub Desktop.

Select an option

Save evgenii-malov/555386ad33c5fb0bcbd429e3e35ba36e to your computer and use it in GitHub Desktop.
-- see video https://www.youtube.com/watch?v=j8r17UrWSyE&t=319s
data Btree a = Leaf a | Node a (Btree a) (Btree a) deriving Show
tr :: Btree Integer
tr_l = Node 1 (Leaf 2) (Leaf 3)
tr_r = Node 4 (Leaf 5) (Leaf 6)
tr = Node 7 tr_l tr_r
all_paths :: Btree a -> [[a]]
all_paths (Leaf a) = [[a]]
all_paths (Node a l r) = (a:) <$> (all_paths l)++(all_paths r)
@evgenii-malov

Copy link
Copy Markdown
Author

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