|
Summary: (a) mult = \ys > if (isNil ys) then 1
else (head ys) * mult (tail ys)
(b) take' = \n > \ys >
if (isNil ys) then Nil
else if (isZero n) then Nil
else Cons (head ys) (take' (pred n) (tail ys))
(c) take'= \n > \ys >
if (isNil ys) then Nil
else if (n == 0) then Nil
else if (n >= 1) then
Cons (head ys) (take' (n1) (tail ys))
else bot
(d) flatList = \ys > if (isNil ys) then Nil
else Cons (fst (head ys))
(Cons (snd (head ys)) (flatList (tail ys)))
exp1 := let greater5 = \x > if x > 5 then True else False in greater 5 y
Val [[exp 1 ]] #
= Val [[let greater5 = #x # if x > 5 then True else False in greater 5 y]] #
= Val [[greater5 y]] (# + {greater5/lfpf})
|