Hi, I’m looking for a solution on the following problem. I’ve tried with funcall, but I think I haven’t understood the concept.
How to add the numbers in a list.
(1 2 3) → 6
Best
Dagfinn
Hi, I’m looking for a solution on the following problem. I’ve tried with funcall, but I think I haven’t understood the concept.
How to add the numbers in a list.
(1 2 3) → 6
Best
Dagfinn
About funcall
: in Lisp you could write something like (funcall '+ 1 2 3)
But this is just equivalent to (+ 1 2 3)
, and indeed this isn’t the most practical in this case, especially if you’re using it graphically in OM, since would then need to prepare the adequate number of inputs in advance.
apply
is probably what you need. It takes a function and then its list of arguments.
(apply '+ (1 2 3))
Thanks a lot for the solution! Perfekt.