Why functional programming matters

I am reading the paper.But I am lost a bit,by this piece-
"sum = reduce add 0".How author arrived to this statement? What it means? And later,
"(reduce f x) nil = x
(reduce f x) (cons a l) = f a ((reduce f x) l)
Here we have written brackets around (reduce f x) to make it clear that it replaces sum." Again,I am not understanding whats happening.
"A function of 3 arguments such as reduce, applied to
only 2 is taken to be a function of the one remaining argument" How reduce is function of 3 arguments?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

reduce has 3 arguments: The

reduce has 3 arguments:

  1. The first argument, a funtion that is going to be used (in the case of sum that is add, in the other cases you give it is named f)
  2. The second argument is the initial value that is going to be used
  3. The third argumment is the list to which reduce is applied, this can be either nil (the empty list), or (cons a l) a list with as first element a

sum = reduce add 0
(reduce add 0) nil = sum nil = 0
(reduce add 0) (cons a l) = add a ((reduce add 0) l) = add a (sum l)

So the sum function has one argument, namely the last argument to reduce.

Thanks for clarifying.As the

Thanks for clarifying.As the author says,
"a function of n arguments applied to only m(< n) is taken to be a function of the n-m remaining ones.".But,when we evaluate reduce,it actually needs 3 arguments.

Original LtU discussion

of the paper is here.