mkgroup.red 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. SYMBOLIC PROCEDURE MKGROUP;
  2. %Expects a list of statements terminated by a >>;
  3. BEGIN SCALAR LST,DELIM;
  4. A: LST := ACONC(LST,XREAD 'GROUP);
  5. IF CURSYM!* EQ '!*RSQB!* THEN GO TO B
  6. ELSE IF NULL DELIM THEN DELIM := CURSYM!*
  7. ELSE IF NOT(DELIM EQ CURSYM!*)
  8. THEN SYMERR("Syntax error: mixed , and ; in group",NIL);
  9. GO TO A;
  10. B: SCAN();
  11. RETURN IF DELIM EQ '!*SEMICOL!* THEN 'PROGN . LST
  12. ELSE 'VECT . LST
  13. END;
  14. PUT('!*LSQB!*,'STAT,'MKGROUP);
  15. NEWTOK '((![) !*LSQB!*);
  16. NEWTOK '((!]) !*RSQB!*);
  17. SYMBOLIC PROCEDURE FORMVECT(U,VARS,MODE);
  18. BEGIN INTEGER N; SCALAR V;
  19. U := FOR EACH X IN U COLLECT FORM1(X,VARS,MODE); % was FORMC
  20. V := MKVECT(LENGTH U-1);
  21. N := 0;
  22. FOR EACH X IN U DO <<PUTV(V,N,X); N := N+1>>;
  23. RETURN V
  24. END;
  25. PUT('VECT,'FORMFN,'FORMVECT);
  26. PUT('VECEXPRP,'EVFN,'EVVECTOR);
  27. SYMBOLIC PROCEDURE !*!*A2S(U,VARS);
  28. IF U = '(QUOTE NIL) THEN NIL
  29. % else if eqcar(u,'for) and not(cadddr u eq 'do)
  30. % then list('foraeval,u)
  31. ELSE IF VECTORP U THEN LIST(!*!*A2SFN,U)
  32. ELSE IF NULL U OR CONSTANTP U AND NULL FIXP U
  33. OR INTEXPRNP(U,VARS) AND NULL !*COMPOSITES
  34. OR NOT ATOM U AND IDP CAR U
  35. AND FLAGP(CAR U,'NOCHANGE) AND NOT(CAR U EQ 'GETEL)
  36. THEN U
  37. ELSE LIST(!*!*A2SFN,U);
  38. SYMBOLIC PROCEDURE VECEXPRP U;
  39. % Determines if U is a valid vector expression.
  40. IF VECTORP U THEN T
  41. ELSE IF ATOM U THEN NIL
  42. ELSE IF CAR U EQ 'PLUS THEN VECEXPRLISP CDR U
  43. ELSE IF CAR U EQ 'TIMES THEN ONEVECEXPRLISP CDR U
  44. ELSE IF CAR U EQ 'MINUS THEN VECEXPRP CADR U
  45. ELSE IF CAR U EQ 'QUOTIENT
  46. THEN VECEXPRP CADR U AND NOT VECEXPRP CADDR U
  47. ELSE NIL;
  48. SYMBOLIC PROCEDURE VECEXPRLISP U;
  49. NULL U OR VECEXPRP CAR U AND VECEXPRLISP CDR U;
  50. SYMBOLIC PROCEDURE ONEVECEXPRLISP U;
  51. IF NULL U THEN NIL
  52. ELSE IF VECEXPRP CAR U THEN NOTVECEXPRLISP CDR U
  53. ELSE ONEVECEXPRLISP CDR U;
  54. SYMBOLIC PROCEDURE NOTVECEXPRLISP U;
  55. NULL U OR NOT VECEXPRP CAR U AND NOTVECEXPRLISP CDR U;
  56. SYMBOLIC PROCEDURE EVVECTOR(u,v);
  57. % Simplification function for a vector expression.
  58. IF VECTORP U THEN EVVECT(U,NIL,NIL)
  59. ELSE NIL;
  60. SYMBOLIC PROCEDURE EVVECT(U,OPR,ARG);
  61. BEGIN INTEGER N; SCALAR V;
  62. N := UPBV U;
  63. V := MKVECT N;
  64. FOR I := 0:N DO PUTV(V,I,
  65. REVAL IF NULL OPR THEN GETV(U,I)
  66. ELSE LIST(OPR,GETV(U,I),ARG));
  67. RETURN V
  68. END;
  69. END;