-- Comp1100 S1 2006
-- Understanding Recursion
-- Clem Baker-Finch March 2006

module Length where
import Prelude hiding (length)

-- A straightforward inductive definition

length :: [a] -> Int
length []      = 0
length (x:xs)  = 1 + length xs

-- Alternative accumulator definition

length' :: [a] -> Int
length' xs  = count xs 0

count :: [a] -> Int -> Int
count []     total  = total
count (x:xs) total  = count xs (total+1)

