[Haskell-cafe] bit of help with n-ary please...

Ketil Malde ketil at malde.org
Mon Nov 9 02:42:18 EST 2009


spot135 <aca08sas at shef.ac.uk> writes:

> So this is what ive got so far.
>
> data Tree a = Empty | Leaf a | Branch a [Tree a]

[Homework mode on, i.e. hints and careful nudges to help you work it out
on your own]

The definition above gives two ways to build a Tree with only one data
element.  Can you see which ones?  Is this a good thing?

What is the difference between your definition and

     data Tree a = Empty | Branch a [Tree a]

What would the consequences be if you replaced your definition with
this one?

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants


More information about the Haskell-Cafe mailing list