module
export map, pam, mm, mp, mmEg, mpEg;

rec
    sqr x = x*x and succ n = n+1 and id x = x  -- some arb' fns

and map f []     = [] ||
    map f (x.xs) = (f x).(map f xs)

and pam [] x     = [] ||
    pam (f.fs) x = (f x).(pam fs x)

and mm = map map
and mp = map pam

and mmEg = mm [sqr; succ]                    -- = [map sqr; map succ]
and mpEg = mp [[sqr; succ]; [id; sqr]]       -- = [pam[sqr;succ]; pam[ed;sqr]]

-- and pm = pam map       give errors, pam's param must be a list of functions
-- and pp = pam pam       not a single function such as map or pam

end

-- map and pam, from csc3030 Programming Paradigms Exam Q3 1995.
-- see also the   ---.t file

