Assume I have a procedure upto
that when called like (upto 1 10)
will generate the list '(1 2 3 4 5 6 7 8 9 10)
.
If I want to use this list as arguments to a function like lcm
that takes multiple arguments rather than a single list, like (lcm 1 2 3 4 5 6 7 8 9 10)
is there a way to do this?
One way I found to do this using eval is the following:
(eval (cons 'lcm (upto 1 10)))
In MIT-Scheme (unsure of others) you can use the dot in your function definition.
Calling with
will do the job. Note that the args get put into a list.
Fun fact: the `list' procedure is actually defined in list.scm of the MIT-Scheme "runtime" source as:
Use apply: e.g
"apply" applies a function to a list of arguments.