File: Tree.lhs

package info (click to toggle)
haskell98-tutorial 200006-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 624 kB
  • ctags: 11
  • sloc: haskell: 2,125; makefile: 80; sh: 13
file content (9 lines) | stat: -rw-r--r-- 266 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
> module Tree ( Tree(Leaf,Branch), fringe ) where

Tree(..) would work also

> data Tree a = Leaf a | Branch (Tree a) (Tree a)   deriving Show

> fringe :: Tree a -> [a]
> fringe (Leaf x)             = [x]
> fringe (Branch left right)  = fringe left ++ fringe right