views:

67

answers:

1

Let's say I have a procedure foo that takes three arguments, and returns a list of them all doubled:

(define  (foo a b c)
  (list (* 2 a ) (* 2 b) (* 2 c)))

What I'd like to be able to do is create another procedure which accepts a list, and calls foo using the list elements as arguments, like this:

(define (fooInterface myList)
  ...)

(fooInterface (list 1 2 3))

The catch is, I don't want to write fooInterface assuming foo will always have 3 arguments. That is, if I add an extra argument to foo, fooInterface should still work provided the list passed in has 3 elements.

+4  A: 

What you're looking for is called apply.

Eli Barzilay
Perfect, thanks!
Cam