using define inside a function



I have a simple simpson's one third rule
code in simpson.mac, and want to define
a local function (inside another function)
to call simp1 for given values
of one of the expression variables, but am
not succeeding.

In what follows, I use two different methods
(in test1 and test2 respectively)
to define the local function h(x) (or h(var)).

----------------------------------------------
Maxima 5.25.1 http://maxima.sourceforge.net
using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (a.k.a. GCL)

(%i1) load(simpson);

(%o1) "c:/work2/simpson.mac"

(%i2) trace(simp1)$

(%i3) simp1(0.5*v^2,v,0,1,4);

1 Enter simp1 [0.5*v^2,v,0,1,4]
1 Exit  simp1 0.16666666666667
(%o3) 0.16666666666667

(%i4) test1(expr,x,y) :=
   block(local(h),
   define( h(x),apply('simp1,[expr,y,0,1,4] ) ),
    print(" h(0.2) = ",h(0.2)),
    print(" h(0.5) = ",h(0.5)),
    disp ("bye"))$

(%i5) test1(u*v^2,u,v)$

1 Enter simp1 [u*v^2,v,0,1,4]
1 Exit  simp1 0.33333333333333*u
 h(0.2) =  0.066666666666667
 h(0.5) =  0.16666666666667
"bye"

(%i6) test2(expr,x,y) :=
   block([var],local(h),
    define( h(var),apply('simp1,[subst(var,x,expr),y,0,1,4] ) ),
    print(" h(0.2) = ",h(0.2)),
    print(" h(0.5) = ",h(0.5)),
    disp ("bye"))$

(%i7) test2(u*v^2,u,v)$

1 Enter simp1 [v^2*var,v,0,1,4]
1 Exit  simp1 0.33333333333333*v
 h(0.2) =  0.33333333333333*v
 h(0.5) =  0.33333333333333*v
"bye"
---------------------------------------------------
What am I doing wrong here?

Ted Woollett