On 10/27/07, Peter Danenberg <pcd at wikitex.org> wrote:
> insertrows(A, B, i) := block([n],
> head(A, n) :=
> if n > 0
> then head(submatrix(length(A), A), n - 1)
> else A,
> tail(A, n) :=
> if n > 0
> then tail(submatrix(1, A), n - 1)
> else A,
> n: length(A),
> addrow(head(A, n - i), B, tail(A, i)));
As it happens, function definitions in Maxima are global by default.
(So are variable bindings as well.) Maxima doesn't have a notion
of lexical scope. To prevent the definitions of head and tail from
leaking out of the block, you could write block(local(head, tail), ...).
That might be the effect you want, although head and tail are then
redefined every time insertrows is called.
best
Robert Dodier