summaryrefslogtreecommitdiffstats
path: root/listlen.hs
blob: cb60aef583e9afa0361976011ec99233f52add59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-- compute length of list


listlen :: [a] -> Int
listlen2 :: [a] -> Int -> Int

listlen ( x:xs )    = listlen2 xs 1
listlen2 ( x:xs ) n = listlen2 xs (n + 1)
listlen2 [] n       = n

myReverse (x:xs)  = myReverse xs ++ [x]
myReverse []      = []

makePalin x       = x ++ myReverse x