different behaviour of lambda() inside and outside functions



Without studying your code in detail, one construct in it caught my eye.

You say something like:

    f(u) := ....  ''u  ...          (two single-quotes)

The construct ''u means "substitute the value of u at read time".  That is,
the parameter u will have no effect on the u inside the function.

Example:

      u: 'outside$
      f(u):= ''u $
      f('inside) => outside

To see why, look at the definition of f:

     dispfun(f) =>
           f(u) := outside

Could this be the source of your problem?

              -s