Task

Create a function, compose,   whose two arguments   f   and   g,   are both functions with one argument.



The result of compose is to be a function of one argument, (lets call the argument   x),   which works like applying function    f    to the result of applying function    g    to    x.



Example

 compose(f, g) (x) = f(g(x))



Reference: Function composition

Hint: In some languages, implementing compose correctly requires creating a closure.




HAI 1.3
 
I HAS A fx, I HAS A gx
 
HOW IZ I composin YR f AN YR g
    fx R f, gx R g
    HOW IZ I composed YR x
        FOUND YR I IZ fx YR I IZ gx YR x MKAY MKAY
    IF U SAY SO
    FOUND YR composed
IF U SAY SO
 
HOW IZ I incin YR num
    FOUND YR SUM OF num AN 1
IF U SAY SO
 
HOW IZ I sqrin YR num
    FOUND YR PRODUKT OF num AN num
IF U SAY SO
 
I HAS A incsqrin ITZ I IZ composin YR incin AN YR sqrin MKAY
VISIBLE I IZ incsqrin YR 10 MKAY BTW, prints 101
 
I HAS A sqrincin ITZ I IZ composin YR sqrin AN YR incin MKAY
VISIBLE I IZ sqrincin YR 10 MKAY BTW, prints 121
 
KTHXBYE