lisp operator losop;
lisp procedure losop(m,n,koplist,coplist);
begin
  koplist:=if atom koplist then list(koplist) else koplist;
  for i:=m:n do begin algebraic write i; elim(i,koplist,coplist) end; 
  algebraic write "Totaal ",totaal(koplist),
    " coefficienten opgelost";
end$

lisp operator totaal;
lisp procedure totaal oplist;
for each el in oplist sum length get(el,'kvalue)$

lisp operator oplosmogelijkheid;
lisp procedure oplosmogelijkheid(m,n,l);
'list . for i:=m:n conc 
   if solvable_kernels(list('num,list('equ,i)),
                       reval 'allowed_opr,reval 'forbidden_opr) neq '(list) 
   then if algebraic(length num equ i) <= l then 
     list list('list,i,algebraic num length(equ i)) else nil$

algebraic procedure propl l;
for each el in l do write first el,"  ",equ first el$

lisp operator elim;
lisp procedure elim(i,koplist,coplist);
  begin scalar lijst;
    lijst:=cdr solvable_kernels(list('equ,i),koplist,coplist);
    if lijst then 
   %verandering paul 
if (lijst:=ordlist lijst) then 
   %einde verandering paul 
      <<
        linear_solve_and_assign(list('equ,i),car lijst);
        setk(list('equ,i),0); lijst:=car lijst;
        terpri();varpri(list('list,i,lijst),nil,t);
      >>;
  end$

lisp procedure ordlist u;
ordlist1(u,nil)$

lisp procedure ordlist1(u,v);
if null u then v
else ordlist1(cdr u,ordlist2(car u,v))$

lisp procedure ordlist2(x,v);
if ordp(x,car v) then x . v
else car v . ordlist2(x,cdr v)$

lisp operator schoonop;
lisp procedure schoonop i;
begin scalar ol;
  ol:=cdr multi_coeff(list('equ,i),cdr reval 'vars);
  if length ol=1 then return i;
  if car ol neq 0 then equ(put_equations_used(equations_used()+1)):=car ol;
  for each el in cdr ol do equ(put_equations_used(equations_used()+1)):=caddr el;
  equ(i):=0;
  return equations_used();
end$

procedure hl(m,n,l); 
  for i:=m:n do if length num equ i<=l and equ i neq 0 
    then elim(i,allowed_opr,forbidden_opr) else if remainder(i,10)=0 then write i$

procedure h i;elim(i,allowed_opr,forbidden_opr)$

lisp operator clean;
lisp procedure clean i;
begin scalar ol;
  ol:=cdr operator_coeff(list('equ,i),'ext);
  if car ol neq 0 then equ(pte(te+1)):=car ol;
  for each el in cdr ol do
    equ(pte(te+1)):=caddr el;
  equ(i):=0;
  return te;
end$

procedure prl(m,n,l);
for i:=m:n do if length equ i<=l and equ i neq 0 then write i,"  ",equ i$

end;
