diff options
Diffstat (limited to 'listlen.hs')
-rw-r--r-- | listlen.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/listlen.hs b/listlen.hs new file mode 100644 index 0000000..cb60aef --- /dev/null +++ b/listlen.hs @@ -0,0 +1,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 |