sl2psl.red 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. module sl2psl; % Definitions of functions in PSL but not SL.
  2. % Some of these are already in the standard REDUCE now.
  3. deflist('((fixp 1) (numberp 1) (floatp 1) (evenp 1) (oddp 1)
  4. (stringp 1) (idp 1) (ordp 2) (nordp 2) (equal 2)
  5. (geq 2) (leq 2)),'number!-of!-args);
  6. %symbolic procedure lastcar l;
  7. % if atom l then l else
  8. % if atom cdr l then car l else car lastpair cdr l;
  9. symbolic procedure lconc(l1,l2);
  10. % Both arguments are lists l1 is a list of the type
  11. % ((a b c ... f) f)
  12. % Useful for concatenating lists from right to left without copying.
  13. % l1 may be nil to start with.
  14. % REQUIRED FOR FUTURE RELEASE
  15. if null l1 then rplacd(list l2,lastpair l2) else
  16. if null car l1 then rplacd(rplaca(l1,l2),l2) else
  17. <<rplacd(cdr l1 ,l2); rplacd(l1, lastpair l2)>>;
  18. symbolic procedure tconc(l,elm);
  19. <<elm:=cons(elm,nil);
  20. if null l then nconc(list elm,elm) else
  21. if null car l then rplacd(rplaca(l,elm),elm) else
  22. <<rplacd(cdr l,elm);rplacd(l,elm)>>
  23. >>;
  24. symbolic procedure adjoin(elm,st);
  25. % elm is any object, st is a set.
  26. if member(elm,st) then st else cons(elm,st);
  27. symbolic procedure list2set u;
  28. % Eliminates redundant elements .
  29. % Replaces !:mkset u of the old ASSIST package.
  30. if null u then nil else if member(car u,cdr u) then list2set cdr u
  31. else car u . list2set cdr u;
  32. symbolic procedure delqip1(elm,l);
  33. if not atom cdr l then
  34. if elm eq cadr l then rplacd(l,cddr l) else
  35. delqip1(elm,cdr l);
  36. symbolic procedure delqip(elm,l);
  37. % Deletes elm from l without copying l.
  38. % This is the good definition given by Arthur Norman.
  39. % Used in the function SYMMETRIZE.
  40. if atom l then l else
  41. if elm eq car l then cdr l else
  42. <<delqip1(elm,l);l>>;
  43. endmodule;
  44. end;