Improving offline narrowing-driven partial evaluation using size-change graphs

 






Jump to...


- schg page


Example: function reverse

[ Original program ]  [ Annotated program ]

Original 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
        


Annotated program
[ go top ]

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 ]