1

Suppose I have a bunch of functions such as g(x0,x1,x2,x3,x4) := x0+x1+x2+x3+x4+x5. I would like to use them in other expressions, but explicitly enumerating all the variables x0,...,x4 is cumbersome. How to shorthand it? I tried something like vars : [x0,x1,..,x4] and then passing it like so g(vars), but of course vars is considered as a single argument in this case, and I get an error. What I need to do?

EDIT: I was asking for something tad simpler. In my case, the answer would be something like "create aliases", G1 : g1(x0,...,x4) etc kind of thing. But the answer below highlights a useful thing to know.

Ilonpilaaja
  • 1,169
  • 2
  • 15
  • 26

1 Answers1

3

You should use apply as stated in the manual 36.4:

(%i1) L : [1, 5, -10.2, 4, 3];
(%o1)                 [1, 5, - 10.2, 4, 3]
(%i2) apply (min, L);
(%o2)                        - 10.2
Thomas Baruchel
  • 7,236
  • 2
  • 27
  • 46