ratsimp and many terms to collect



   >From mailnull  Wed May 15 13:30:23 2013
   Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of math.utexas.edu designates 146.6.25.7 as permitted sender) client-ip=146.6.25.7; envelope-from=maxima-bounces at math.utexas.edu; helo=ironclad.mail.utexas.edu;
   From: Zbigniew Komarnicki <cblasius at gmail.com>
   Date: Wed, 15 May 2013 15:29:00 +0200
   Content-Type: text/plain; charset="us-ascii"

   Hello,

   I have equation
   e1: (a*x(l,p-1)-b*x(l-1,p-1))*C3+(a*x(l+1,p-1)-b*x(l,p-1))*C2
       +(a*x(l+2,p-1)-b*x(l+1,p-1))*C1+(a*x(l,p)-b*x(l-1,p))*B3
       +(a*x(l+1,p)-b*x(l,p))*B2+(a*x(l+2,p)-b*x(l+1,p))*B1
       +(a*x(l,p+1)-b*x(l-1,p+1))*A3+(a*x(l+1,p+1)-b*x(l,p+1))*A2
       +(a*x(l+2,p+1)-b*x(l+1,p+1))*A1;

   I need to collect terms around variable 'x( , )'. I do it in the following way:

   Make needed terms
   Lx: flatten( makelist([x(l+3-i,p+1), x(l+3-i,p), x(l+3-i,p-1)], i,1,3));

   and then put it by hand to 'ratsimp'
   e2: ratsimp(e1, Lx[1], Lx[2], Lx[3], Lx[4], Lx[5], Lx[6], Lx[7], Lx[8], Lx[9]);

   It works, but is very tedious writing every Lx[i], i=1,..,9.

   Is it maybe possible to make it in the following way:
   /* this of course does not work - do not collect around x( , ) */
   e2: ratsimp(e2, Lx);  

   giving a whole list 'Lx' at once or how to make sequence of arguments Lx[1],...,Lx[9] to 'ratsimp' ?
   Is there a better solution to this problem?

   Thank you in advance.

   Zbigniew

You seem to want to use `apply'. This lets you build up the argument
list to a function, then apply the function to the argument list:

apply(function, arglist);

Leo