mini-easy-sl.red 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. % MINI-EASY-SL.RED --- Simple functions
  2. % --- Some basic predicates
  3. % Note that the bodies open copile, so this is just for
  4. % interpreter entries
  5. Procedure Atom x;
  6. Atom x;
  7. % Simple LIST stuff
  8. Procedure append(U,V);
  9. if not PairP U then V
  10. else Cons(Car U,Append(Cdr U,V));
  11. Procedure MemQ(x,y);
  12. If Not PAIRP y then NIL
  13. else if x EQ car y then T
  14. else MemQ(x, cdr y);
  15. Procedure REVERSE U;
  16. Begin Scalar V;
  17. While PairP U do <<V:=CONS(Car U,V);
  18. U:=CDR U>>;
  19. Return V;
  20. End;
  21. % Simple EVAL support
  22. procedure Evlis x;
  23. if Not Pairp x then x
  24. else Eval(car x) . Evlis(cdr x);
  25. procedure EvProgn fl;
  26. Begin scalar x;
  27. While PairP fl do <<x:=Eval Car fl;
  28. fl:=Cdr fl>>;
  29. Return x;
  30. End;
  31. fexpr procedure Progn x;
  32. EvProgn x;
  33. procedure EvCond fl;
  34. if not PairP fl then 'NIL
  35. else if not PairP car fl then EvCond cdr fl
  36. else if Eval car car fl then EvProgn cdr car fl
  37. else EvCond cdr fl;
  38. fexpr procedure Cond x;
  39. EvCond x;
  40. Fexpr Procedure Quote a;
  41. Car a;
  42. Fexpr Procedure SETQ a;
  43. Set(car a,Eval Cadr a);
  44. fexpr Procedure De(x);
  45. PutD(car x,'Expr,'LAMBDA . cdr x);
  46. fexpr Procedure Df(x);
  47. PutD(car x,'Fexpr,'LAMBDA . Cdr x);
  48. fexpr Procedure Dn(x);
  49. PutD(car x,'NExpr,'LAMBDA . cdr x);
  50. fexpr Procedure Dm(x);
  51. PutD(car x,'Macro,'LAMBDA . Cdr x);
  52. nexpr procedure List x;
  53. x;
  54. End;