Please help me debug this




On Fri, 25 Jun 2010, Jeffrey Hankins wrote:

< Thanks, Leo. This is what is happening in Maxima:
< 
< drop (L,n) := if n=1 then delete(mini(L),L,1) else drop(drop(L,n-1),1);
< drop(L,n):=if n=1 then delete(mini(L),L,1) else drop(drop(L,n-1),1)
< 
< replace (L,x) := if x>mini(L) then cons(x,drop(L,1)) else L;
< replace(L,x):=if x>mini(L) then cons(x,drop(L,1)) else L
< 
< finalgrade (dq,midterm,final) := ([fg],
< dq: drop(dq,2),
< midterm: replace(midterm,final),
< fg: 3*sum(dq[i],i,1,13)/13+(midterm[1]+midterm[2])/5+3*final/10,
< if fg>=89.5 then print("student got an A")
< elseif fg>=84.5 then print("student got a B+")
< elseif fg>=79.5 then print("student got a B")
< elseif fg>=74.5 then print("student got a C+")
< elseif fg>=69.5 then print("student got a C")
< elseif fg>=66.5 then print("student got a D+")
< elseif fg>=59.5 then print("student got a D")
< else print("student got an F"), fg)$
< 
< needgrade (dq,midterm,desired) := ([need,lower,cutoff],
< dq: drop(dq,2),
< lower: lmin(midterm),
< cutoff: 3*sum(dq[i],i,1,13)/13+(midterm[1]+midterm[2])/5+3*lower/10,
< if desired>cutoff then block([],
< drop(midterm,1),

Change the line above to
midterm : drop(midterm,1),


< need: 2*(desired-3*sum(dq[i],i,1,13)/13-midterm[1]/5))
< else need: 10/3*(desired-3*sum(dq[i],i,1,13)/13-(midterm[1]+midterm[2])/5),need)$
< 
< needgrade([10,10,0,10,10,10,10,10,0,10,0,10,10,10,10],[62,85],8.45b1);
< 8.881538461538462b1
< 
< finalgrade([10,10,0,10,10,10,10,10,0,10,0,10,10,10,10],[62,85],8.88b1);
< "student got a B+"
< 8.909230769230769b1
 
I get, with the one change above, and my earlier change to use 'block',

needgrade([10,10,0,10,10,10,10,10,0,10,0,10,10,10,10],[62,85],84.5);
finalgrade([10,10,0,10,10,10,10,10,0,10,0,10,10,10,10],[62,85],%);

(%o7) 79.61538461538461
(%i8) student got a B+
(%o8) 84.5

which is what you want, if I understood correctly.

Leo

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.