Tried to mimic the reverse
function to the ADT List
below,
data List a = Nil | Cons a (List a) deriving (Show)
reverseList = convert . reverse'
where
reverse' Nil = []
reverse' (Cons x list) = reverse' list ++ [x]
convert [] = Nil
convert (x:xs) = Cons x (convert xs)
The reverseList
is composed of convert
and reverse'
, how to achieve it optimally for instance without the aid of the built-in list?