Skip to content

Instantly share code, notes, and snippets.

@Lysxia
Lysxia / BinTrees.hs
Last active October 23, 2015 15:11 — forked from meditans/BinTrees.hs
Enumerating BinTrees by depth
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)