Skip to content

Instantly share code, notes, and snippets.

Lysxia / BinTrees.hs
Last active Oct 23, 2015 — forked from meditans/BinTrees.hs
Enumerating BinTrees by depth
View BinTrees.hs
import qualified Control.Monad.WeightedSearch as W
import Data.List (sortBy)
import Data.Ord (comparing)
import Control.Applicative
data BTree = Leaf | Branch BTree BTree deriving (Show, Eq)
-- I can lazily list all the btrees
btrees :: W.T Integer BTree
btrees = pure Leaf <|> W.weight 1 (Branch <$> btrees <*> btrees)
You can’t perform that action at this time.