You are on page 1of 1

MSU-Iligan Institute of Technology

CSC 102
First Semeter 2014
Machine Problem 4
First Class Values. 100 points.
1 !0 "oints #et fan$ gbe t%o one-argument functions The compositionfafter gis $efine$ to be
the function x => f (g(x)) &efine a function com"ose that im"lements com"osition For e'am"le(
if incis a "roce$ure that a$$s 1 to its argument(
compose (square, inc) 6 => 49
2 !0 "oints If fis a numerical function an$ nis a "ositi)e integer( then %e can form the n
th
re"eate$
a""lication of f( %hich is $efine$ to be the function %hose )alue at xis f (f (. . . (f
(x )) . . . )) For e'am"le( if fis the function ' *+ ' , 1( then the n
th
re"eate$ a""lication of fis
the function ' *+ ' , n If fis the o"eration of s-uaring a number( then the n
th
re"eate$ a""lication of f
is the function that raises its argument to the 2
n
-th "o%er .rite a function that ta/es as in"uts a
function that com"utes fan$ a "ositi)e integer nan$ returns the function that com"utes the n
th
re"eate$
a""lication of f 0our function shoul$ be able to be use$ as follo%s1
repeated (square 2) 5 => 625
2int1 0ou may fin$ it con)enient to use compose.
C
y
r
u
s

G
.

G
a
b
i
l
l
a

You might also like