list - Why does this function give rise to an infinite loop? -
i trying solve exercises haskell course found online , this question, have following implementation:
reverse :: list -> list reverse nil = nil reverse (x :. xs) = let l = (reverse xs) in l ++ (x:.nil)
with list
being defined as:
data list t = nil | t :. list t deriving (eq, ord)
it seems there infinite loop inside function. not find out why. enlighten me?
this correct implementation of reverse
definition of list
in exercise book. if there infinite loop somewhere in implementation of (++)
.
Comments
Post a Comment