我有这个数据类型
datatype e = X | Const of int | P of e*e | S of e*e | M of e*e | D of e*e;
和这个程序
val rec evl = fn (Const k)=>(fn x=>k)| X=> (fn x=>x)| P(e1,e2)=> (fn x=> (evl e1 x)+(evl e2 x))| S(e1,e2)=> (fn x=> (evl e1 x)-(evl e2 x))| M(e1,e2)=> (fn x=> (evl e1 x)*(evl e2 x))| D(e1,e2)=> (fn x=> (evl e1 x)/(evl e2 x));
如何扩展此数据类型和 evl 过程:
-val addsub = evl( A( X(1),X(2),X(3), S( X(4),X(5) ) )) ; addsub(4,5,2,9,8) 返回它 = 12 (4+5+2+(9-8))
P = +, S = -, M = * , D = / 而不仅仅是 X(5),我需要 X(n) ...?