user3522238
user3522238

Reputation: 11

How do I use arguments instead of a list?

I have it like this (sigma (list 1 2 3 2 1)) and I need it like this (sigma 1 2 3 2 1). I think I need a function to convert it or rewrite it to make it work.

Upvotes: 0

Views: 33

Answers (1)

Óscar López
Óscar López

Reputation: 236124

Try this:

(define (sigma . args)
  ...)

That's the syntax for having a variable number of arguments, now you can call it like this:

(sigma 1 2 3 2 1)

And inside your procedure, treat args as a list of arguments to do whatever you need with them.

Upvotes: 1

Related Questions