Jac
Jac

Reputation: 101

How to evaluate a function giving a value in scheme

(F n m l f g): n and m are natural numbers, l a list of numbers, f and g functions that take a numeric parameter and return a number. The F function should return:

enter image description here

I need to program this function in scheme. And I have developed a function for the product but not how to perform the evaluation of the role, I tried with the eval command but not worked yet

Any help on how to do?

Upvotes: 0

Views: 154

Answers (1)

C. K. Young
C. K. Young

Reputation: 223183

Here's a straightforward translation of your formula to Racket:

(define (F n m l f g)
  (for/sum ([i (in-range 1 (add1 n))])
    (- (f (expt m i))
       (g (for/product ([j (in-list l)])
            (expt j i))))))

Upvotes: 6

Related Questions