<< Prev | - Up - | Next >> |
We need to auxilariy functions to compute weighted sums and products for a given range of integers.
These functions can be easily defined by recursive procedures (or alternatively by looping relative to a global cells containing an integer):
%% defines weighted sums and products
functor
import
export
Sum
Prod
define
fun{Sum N M F}
if M==N-1 then 0 else {F N}+{Sum N+1 M F} end
end
fun{Prod N M F}
if M==N-1 then 1 else {F N}*{Prod N+1 M F} end
end
end
<< Prev | - Up - | Next >> |