1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
/* -*- MACSYMA -*- */
eval_when(batch,ttyoff:true)$
/*ASB;LRATS 3
5:05pm Tuesday, 14 July 1981
7:53pm Saturday, 29 May 1982
Added a DIAGEVAL_VERSION for this file.
1:43pm Saturday, 12 June 1982
Changed loadflags to getversions, DEFINE_VARIABLE:'MODE.
*/
eval_when(translate,
define_variable:'mode,
transcompile:true)$
put('lrats,3,'diageval_version)$
define_variable(messlrats2,"Invalid argument to FULLRATSUBST:",any)$
define_variable(fullratsubstflag,false,boolean)$
lratsubst(listofeqns,exp):=block(
[partswitch:true,inflag:true,piece],
if not listp(listofeqns)
then if inpart(listofeqns,0)="="
then listofeqns:[listofeqns]
else if fullratsubstflag=true
then error(messlrats2,[listofeqns,exp])
else error("Invalid argument to LRATSUBST:",[listofeqns,exp]),
for idum in listofeqns do
if inpart(idum,0)#"="
then if fullratsubstflag=true
then error(messlrats2,[listofeqns,exp])
else error("Invalid argument to LRATSUBST:",[listofeqns,exp]),
lratsubst1(listofeqns,exp))$
lratsubst1(listofeqns,exp):=block(
[dum:if listofeqns=[]
then exp
else if rest(listofeqns)=[]
then ratsubst(inpart(listofeqns,1,2),inpart(listofeqns,1,1),exp)
else lratsubst1(rest(listofeqns),
if fullratsubstflag=true
then fullratsubst1(inpart(listofeqns,1,2),
inpart(listofeqns,1,1),
exp)
else ratsubst(inpart(listofeqns,1,2),
inpart(listofeqns,1,1),
exp))],
declare(dum,special),
if fullratsubstflag=true and dum#exp
then lratsubst1(listofeqns,dum)
else if dum#exp
then dum
else exp)$
fullratsubst1(substexp,forexp,exp):=block(
[dum:ratsubst(substexp,forexp,exp)],
if dum=exp
then exp
else fullratsubst1(substexp,forexp,dum))$
fullratsubst([arglist]):=block(
[fullratsubstflag:true,larglistdum:length(arglist),farglist,
partswitch:true,inflag:true,piece],
if larglistdum=2
then if listp(farglist:first(arglist)) or inpart(farglist,0)="="
then lratsubst(farglist,last(arglist))
else error(messlrats2,arglist)
else if larglistdum=3
then apply('fullratsubst1,arglist)
else error(messlrats2,arglist))$
eval_when(batch,ttyoff:false)$
|