[Haskell-cafe] Building a tree?

wren ng thornton wren at freegeek.org
Wed Jun 10 20:13:20 EDT 2009


michael rice wrote:
> Here's a function from Data.Tree:
> 
> unfoldTree :: (b -> (a, [b])) -> b -> Tree a
> Build a tree from a seed value
> 
> Could someone please give me a brief example of usage.

     Data.Tree> let t = unfoldTree (\i -> (show i, [i`div`2..i-1]))
     Data.Tree> putStr . drawTree $ t 8

-- 
Live well,
~wren


More information about the Haskell-Cafe mailing list