green's functions, passing functions to a routine



Hi,

I am trying to find convenient ways to deal with a
one dimensional Green's function problem. Here are some
questions that came up.

1) how can one pass functions as arguments to another function?
   Eg,
  
  /*WRONG*/
  ygen(f,x,L) :=  integrate(f(t)*g2(x,t),t,0,x) 
         + integrate(f(t)*g1(x,t),t,x,L);

  this does not do what I am trying to do.

2) I want to integrate g1 and make a function h1 from the
   result. Is there  a good idiom? This seems to work ok.

   h1(x,t) := ''(ratsimp(integrate(g1(x,t),t)));

3) Piecewise defined functions.
   f(x) := if x > 3 then 0 else x;
   integrate(f(x),[x,0,4]); /* FAILS */
   fails to give a useful result.
   Of course, eventually, one would like a more complicated
   problem with 3 replaced by say, a.

I can supply other details of the problem if necessary.

Thanks,
John