Exemplo n.º 1
0
def dotProduct(addOp, mulOp, *vectors):
    f = fcp() * $reduce(addOp) * $imap(mulOp)
    return f(*vectors)
Exemplo n.º 2
0
def f1(x):
    return x * 2


def f2(x):
    return x + 2


def f3(x):
    return x ** 2


# function composition example
print f3(f2(f1(3)))
F = (fcp() * f3 * f2 * f1)
print F(3)
print
# the result of the above two computation must be the same

# function composition and currying example
F = fcp() * $mul(2) * $add(1)
print F(2)
print


def isOdd(x):
    return (x % 2) != 0


def takeN(N, it):