Begin with the standard definition of filter
:
filter : (alpha -> bool) x list(alpha) -> list(alpha)
Now perform the following steps:
- convert the code to CPS
- make the stack an explicit list of structures
- remove arguments and return values;
use global registers instead
- convert the stack from a list to a vector
(you may use global variables and mutate them,
but be reasonable)
Turn in the result from each stage.
You may assume that the person using your code provides:
- an appropriately CPSed function as the first argument;
- any
sr/
structures necessary to put on the stack
to execute their own procedure (but not for
the transformed version of filter
);
- the
cond
-clauses in Pop
necessary
to handle those new stack frame types.
You must do all the other transformation necessary.