xvect.red 679 B

12345678910111213141516171819202122232425262728293031
  1. module xvect; % Support for vectors with adaptive length.
  2. % Author: Herbert Melenk, ZIB-Berlin.
  3. % Note: CSL version uses 1024, PSL 128.
  4. symbolic procedure mkxvect(); {mkvect(1024)};
  5. symbolic procedure xputv(v,n,w);
  6. begin scalar i,j;
  7. i:=iquotient(n,1024); j:=iremainder(n,1024);
  8. while(i>0) do
  9. <<if null cdr v then cdr v:= mkxvect();
  10. v:=cdr v; i:=i #- 1>>;
  11. iputv(car v,j,w);
  12. return w;
  13. end;
  14. symbolic procedure xgetv(v,n);
  15. begin scalar i,j,w;
  16. i:=iquotient(n,1024); j:=iremainder(n,1024);
  17. while(i>0 and v) do
  18. <<v:=cdr v; i:=i #- 1>>;
  19. w:=if v then igetv(car v,j);
  20. return w
  21. end;
  22. endmodule;
  23. end;