|
|
|
|
[ Original program ] [ Annotated program ] This program contains the implementation of de reverse function by using the append function.
rev [] = []
rev (x:xs) = app (rev xs) (x:[])
app [] y = y
app (x:xs) y = x: app xs y
In this example no annotations are introduced by size-change
graphs analysis nor by linearity restrictions.
module reverseS where
GEN :: a -> a
GEN x
| success
= x
rev :: [a] -> [a]
rev [] = []
rev (x:xs) = app (rev xs) [x]
app :: [a] -> [a] -> [a]
app [] y = y
app (x:xs) y = (x:(app xs y))
[ go top ] |