I'm trying to define multiplication over functions in Python, in pseudocode this is:
This should return a function in x, given f(x), g(x)
multiply_two_functions((f(x), g(x)) = f(x) * g(x)
I can do this in Haskell like so:
mult :: (Num b) => (a -> b) -> (a -> b) -> (a -> b)  
mult f g = h
    where h x = (f x) * (g x)
You might ask why I'd want to do this - I have a list of functions [f], and I want to reduce these with multiplication. Again, in Haskell:
reduce_mult list = foldl mult 1 list
Edit: How I'm using it in python, for completeness:
def prod_reduce(f_list):
    def identity(x):
        return 1
    def f_mult(f, g):
        def multiplied(x):
            return f(x) * g(x)
        return multiplied
    prod = identity
    for f in f_list:
        prod = f_mult(prod, f)
    return prod
Does anyone have any tips for the Python implementation?
 
     
     
     
    