Oct 6, 2003 ------------- - More functions - writing a recursive square function - writing a powerset function - using a "let" inside it - to prevent recomputing - composing functions - Codes written today fun square(0) = 0 | square(x) = square(x-1) + 2*x -1; fun inserteverywhere(x,nil) = nil | inserteverywhere(x,L::Ls) = (x::L)::inserteverywhere(x,Ls); fun powerset([]) = [nil] | powerset(x::xs) = let val y = powerset(xs) in inserteverywhere(x,y)@y end; fun f1(x) = x+2; fun f2(x) = x*3; fun identity(x) = x; fun cool(F,G) = let fun C(x) = G(F(x)) in C end; val C = cool(f1,f2); C(3); val D = cool(f2,f1); D(3);