rlfi.red 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. %***********************************************************************
  2. %***** ******
  3. %***** M O D U L E R L F I Ver. 1.2 02/10/1992 ******
  4. %***** ******
  5. %***********************************************************************
  6. %***** Program for LATEX syntax of REDUCE output formulas, ******
  7. %***** to activate it, turn the LATEX switch ON. ******
  8. %***** Program can be used only on systems supporting lower ******
  9. %***** case characters through OFF RAISE. ******
  10. %***********************************************************************
  11. module rlfi;
  12. % Author: Richard Liska
  13. % Faculty of Nuclear Sciences and Physical Engineering
  14. % Czech Technical University in Prague
  15. % Brehova 7, 115 19 Prague 1, Czechoslovakia
  16. % E-mail: tjerl@cspuni12.bitnet (EARN)
  17. % tjerl@aci.cvut.cs (Internet)
  18. % Program RLFI, Version REDUCE 3.4.1 02/10/1992
  19. off echo;
  20. % History:
  21. % Ver. 1.01 17/11/1989 ******
  22. % Ver. 1.1 27/05/1991 ******
  23. % Ver. 1.1.1 27/08/1992 ****** added lists
  24. % Ver. 1.2 02/10/1992 ****** corrected lists, underscores _,
  25. % added all prefix operators from REDUCE kernel and SOLVE,
  26. % subscripts for ARBINT etc., VERBATIM OFF by default -
  27. % prints REDUCE Input: (to avoid empty verbatims), corrected
  28. % repeated printing of longer ids, added ROUNDED numbers
  29. symbolic;
  30. fluid'(posn!* orig!*);
  31. % Global variables and their default values
  32. global '(mstyle!* nochar!* nochar1!* linel!* laline!* ncharspr!*
  33. mstyles!*);
  34. nochar!*:=nil; % List of identifiers longer than one character
  35. % used in previous commands
  36. nochar1!*:=nil; % List of identifiers longer than one character
  37. % in actual command which are used for the first time
  38. laline!*:=72; % Linelength of output file
  39. ncharspr!*:=0; % Position on output line
  40. linel!*:=linelength nil . laline!*; % actual length of line
  41. off raise;
  42. MSTYLE!*:='displaymath; % Default mathematical style
  43. MSTYLES!*:= '(math displaymath equation); % Possible math. styles
  44. % Declaration of symbols and operators for LaTeX
  45. FLAG('(alpha beta gamma delta epsilon varepsilon zeta eta theta vartheta
  46. iota kappa lambda mu nu xi pi varpi rho varrho sigma varsigma tau
  47. upsilon phi varphi chi psi omega Gamma Delta Theta Lambda Xi Pi
  48. Sigma Upsilon Phi Psi Omega infty hbar nabla perp),'SYMBOL);
  49. FLAG('(hat check breve acute grave tilde bar vec dot ddot),'ACCDEF);
  50. DEFLIST('((bold !{!\bf! )(roman !{!\rm! )),'FONTDEF);
  51. DEFLIST('((!( !\left!() (!) !\right!)) (PI !\pi! ) (pi !\pi! )
  52. (E e) (I i)),'NAME);
  53. DEFLIST('((TIMES ! )(SETQ !=)(GEQ !\geq! )(LEQ !\leq! )),'LAPR);
  54. % LaTeX supported operators
  55. DEFLIST('(
  56. (ACOS !\arccos) (COTH !\coth) (SEC !\sec)
  57. (ASIN !\arcsin) (CSC !\csc) (SIN !\sin)
  58. (ATAN !\arctan) (EXP !\exp) (SINH !\sinh)
  59. (ARG !\arg) (LN !\ln) (TAN !\tan)
  60. (COS !\cos) (LOG !\log) (TANH !\tanh)
  61. (COSH !\cosh) (MAX !\max) (SUM !\sum)
  62. (COT !\cot) (MIN !\min) (PRODUCT !\prod)
  63. ),'LAPOP);
  64. ON RAISE;
  65. % Other REDUCE operators
  66. deflist('(
  67. (abs "{\rm abs}") (deg2rad "{\rm deg2rad}")
  68. (acosd "{\rm acosd}") (dilog "{\rm dilog}")
  69. (acosh "{\rm acosh}") (dms2deg "{\rm dms2deg}")
  70. (acot "{\rm acot}") (dms2rad "{\rm dms2rad}")
  71. (acotd "{\rm acotd}") (erf "{\rm erf}")
  72. (acoth "{\rm acoth}") (expint "{\rm expint}")
  73. (acsc "{\rm acsc}") (factorial "{\rm factorial}")
  74. (acscd "{\rm acscd}") (fix "{\rm fix}")
  75. (acsch "{\rm acsch}") (floor "{\rm floor}")
  76. (arbcomplex "{\rm arbcomplex}") (hypot "{\rm hypot}")
  77. (arbint "{\rm arbint}") (icbrt "{\rm icbrt}")
  78. (arbreal "{\rm arbreal}") (ilog2 "{\rm ilog2}")
  79. (argd "{\rm argd}") (impart "{\rm impart}")
  80. (asec "{\rm asec}") (irootn "{\rm irootn}")
  81. (asecd "{\rm asecd}") (isqrt "{\rm isqrt}")
  82. (asech "{\rm asech}") (log10 "{\rm log10}")
  83. (asind "{\rm asind}") (logb "{\rm logb}")
  84. (asinh "{\rm asinh}") (norm "{\rm norm}")
  85. (atan2 "{\rm atan2}") (one_of "{\rm one_of}")
  86. (atan2d "{\rm atan2d}") (perm "{\rm perm}")
  87. (atand "{\rm atand}") (rad2deg "{\rm rad2deg}")
  88. (atanh "{\rm atanh}") (rad2dms "{\rm rad2dms}")
  89. (cbrt "{\rm cbrt}") (repart "{\rm repart}")
  90. (ceiling "{\rm ceiling}") (root_of "{\rm root_of}")
  91. (choose "{\rm choose}") (round "{\rm round}")
  92. (cosd "{\rm cosd}") (secd "{\rm secd}")
  93. (cosh "{\rm cosh}") (sech "{\rm sech}")
  94. (cotd "{\rm cotd}") (sgn "{\rm sgn}")
  95. (cscd "{\rm cscd}") (sind "{\rm sind}")
  96. (csch "{\rm csch}") (sol "{\rm sol}")
  97. (deg2dms "{\rm deg2dms}") (tand "{\rm tand}")
  98. ),'lapop);
  99. symbolic procedure get!*(u,v);
  100. if numberp u then nil else get(u,v);
  101. fluid '(!*latex !*lasimp !*verbatim !*!*a2sfn);
  102. switch latex,lasimp,verbatim;
  103. !*lasimp := t;
  104. symbolic put('latex,'simpfg,'((t (latexon)) (nil(latexoff)) ));
  105. symbolic put('verbatim,'simpfg,'((t (verbatimon)) (nil (verbatimoff))));
  106. symbolic procedure latexon;
  107. % Procedure called after ON LATEX
  108. <<!*!*a2sfn:='texaeval;
  109. !*raise:=nil;
  110. if 'psl memq lispsystem!* then !*lower := nil; % PSL kludge.
  111. prin2t "\documentstyle{article}";
  112. prin2t "\begin{document}";
  113. if !*verbatim then
  114. <<prin2t "\begin{verbatim}";
  115. prin2t "REDUCE Input:">>;
  116. put('tex,'rtypefn,'(lambda(x) 'tex)) >>;
  117. symbolic procedure latexoff;
  118. % Procedure called after OFF LATEX
  119. <<!*!*a2sfn:='aeval;
  120. !*raise:=t;
  121. if 'psl memq lispsystem!* then !*lower := t;
  122. remprop('tex,'rtypefn);
  123. if !*verbatim then
  124. <<terpri();
  125. prin2t "\end{verbatim}" >>;
  126. prin2t "\end{document}";
  127. rmsubs() >>;
  128. procedure verbatimon;
  129. <<if !*latex and null !*verbatim then
  130. <<prin2t "\begin{verbatim}";
  131. prin2t "REDUCE Input:">>;
  132. !*echo:=t>>;
  133. procedure verbatimoff;
  134. <<if !*latex and !*verbatim then
  135. <<terpri();
  136. prin2t "\end{verbatim}">>;
  137. !*echo:=nil >>;
  138. symbolic procedure texaeval u;
  139. % Procedure replaces the AEVAL procedure in the LATEX mode
  140. if !*lasimp then list('tex,aeval u)
  141. else list('tex,u);
  142. % deklarace latex modu;
  143. put('tex,'tag,'tex);
  144. put('tex,'simpfn,'simp);
  145. put('tex,'typeletfn,'texlet);
  146. put('tex,'prifn,'latexprint);
  147. put('tex,'setprifn,'setlaprin);
  148. flag('(tex),'sprifn);
  149. symbolic procedure texlet(u,v,tu,b,tv);
  150. % Assignment procedure for LATEX mode
  151. % !!! match can be evaluated like let!!!!;
  152. if eqcar(v,'tex) then let2(u,cadr v,nil,b)
  153. else msgpri(" value for ",u," not assigned ",v,nil);
  154. symbolic procedure latexprint u;
  155. % Prints expression U in the LaTeX syntax
  156. <<prinlabegin();
  157. latexprin u;
  158. prinlaend() >>;
  159. symbolic procedure setlaprin(u,v);
  160. % Prints assignment command in LaTeX syntax
  161. <<prinlabegin();
  162. latexprin u;
  163. oprinla 'setq;
  164. latexprin v;
  165. prinlaend() >>;
  166. symbolic procedure mathstyle u;
  167. % Defines the output mathematical style
  168. if car u memq mstyles!* then <<mstyle!*:=car u;nil>>
  169. else msgpri(" mathematical style ",car u," not supported ",nil,nil);
  170. put('mathstyle,'stat,'rlis);
  171. symbolic procedure prinlabegin;
  172. % Initializes the output
  173. <<if !*verbatim then
  174. <<terpri();
  175. prin2t "\end{verbatim}">>;
  176. linel!*:=linelength nil . laline!*;
  177. if ofl!* then linelength(laline!* + 2)
  178. else laline!*:=car linel!* - 2;
  179. prin2 "\begin{";
  180. prin2 mstyle!*;
  181. prin2t "}" >>;
  182. symbolic procedure prinlaend;
  183. % Ends the output of one expression
  184. <<terpri();
  185. prin2 "\end{";
  186. prin2 mstyle!*;
  187. prin2t "}";
  188. if !*verbatim then
  189. <<prin2t "\begin{verbatim}";
  190. prin2t "REDUCE Input:">>;
  191. ncharspr!*:=0;
  192. if nochar1!*
  193. then msgpri(" Longer than one character identifiers used ",
  194. nil,nochar1!*,nil,nil);
  195. if ofl!* then linelength(car linel!*)
  196. else laline!*:=cdr linel!*;
  197. nochar!*:=append(nochar!*,nochar1!*);
  198. nochar1!*:=nil >>;
  199. symbolic procedure latexprin u;
  200. % Prints expression U in the LaTeX syntax
  201. if eqcar(u,'tex) then maprintla(cadr u,0)
  202. else maprintla(u,0);
  203. symbolic procedure texprla(u,p);
  204. maprintla(car u,p);
  205. put('tex,'laprifn,'texprla);
  206. symbolic procedure maprintla(l,p);
  207. % L is printed expression, P is the infix precedence of infix operator
  208. % Procedure is similar to that one in the REDUCE source
  209. begin
  210. scalar x;
  211. if null l then return nil
  212. else if numberp l then go to c
  213. else if atom l then return prinlatom l
  214. else if stringp l then return prin2la l
  215. else if not atom car l then return maprintla(car l,p)
  216. else if (x:=get(car l,'laprifn)) and
  217. ((not flagp(car l,'fulla)
  218. and not (apply(x,list(cdr l,p)) eq 'failed))
  219. or (flagp(car l,'fulla) and not(apply(x,list(l,p)) eq 'failed)))
  220. then return l
  221. else if (x:=get(car l,'indexed)) then return prinidop(car l,cdr l,x)
  222. else if x:=get(car l,'infix) then go to a
  223. else if car l eq '!:rd!: then return
  224. begin
  225. scalar !*nat,ll;
  226. % max. estimate
  227. ll:=if floatp cdr l then lengthc cdr l
  228. else lengthc cadr l + lengthc cddr l + 5;
  229. if ncharspr!* + ll > laline!* then
  230. <<terpri();
  231. ncharspr!*:=ll >>
  232. else ncharspr!*:=ncharspr!* + ll;
  233. posn!*:=orig!*;
  234. rd!:prin l
  235. end;
  236. oprinla(car l);
  237. prinpopargs(car l,cdr l,p);
  238. return l;
  239. a:p:=x>p;
  240. if null p and car l eq 'equal then p:=t;
  241. if p then go to b;
  242. prinlatom '!(;
  243. b:inprinla(car l,x,cdr l);
  244. if p then return l;
  245. prinlatom '!);
  246. return l;
  247. c:if not l<0 or p<get('minus,'infix) then return prin2la l;
  248. prin2la '!(;
  249. prin2la l;
  250. prin2la '!);
  251. return l
  252. end;
  253. symbolic procedure prinpopargs(op,args,p);
  254. % Prints argument(s) of prefix operator, decides if arg(s) will be
  255. % enclosed in parantheses
  256. begin
  257. scalar x;
  258. x:=null args or cdr args or not atom car args;
  259. % x:=x or null get(op,'lapop);
  260. if x then prinlatom '!( else prin2la "\,";
  261. if args then inprinla('!*comma!*,0,args);
  262. if x then prinlatom '!);
  263. if null x and p=get('times,'infix) then prin2la "\:";
  264. return args
  265. end;
  266. symbolic procedure prinlatom u;
  267. % Prints atom or the symbol associated to the atom in given font
  268. % and with given accent
  269. begin
  270. scalar n,f,a;
  271. if f:=get(u,'font) then prin2la f;
  272. if a:=get(u,'accent) then prin2la a;
  273. if n:=get(u,'name) then prin2la n
  274. else prin2la testchar1 u;
  275. if a then prin2la "}";
  276. if f then prin2la "}";
  277. return u
  278. end;
  279. symbolic procedure defid u;
  280. % Defines the statement DEFID for defining symbol, font and accent
  281. % associated to given atom
  282. begin
  283. scalar at,x,y;
  284. at:=car u;
  285. if not atom at or null car u then go to er;
  286. a:u:=cdr u;
  287. x:=car u;
  288. if eqcar(x,'equal) then x:=cdr x
  289. else go to er;
  290. if car x eq 'name then
  291. if flagp(cadr x,'symbol)
  292. then put(at,'name,incompe3('!\,cadr x,'! ))
  293. else put(at,'name,testchar1 cadr x)
  294. else if car x eq 'font then
  295. if y:=get(cadr x,'fontdef) then put(at,'font,y)
  296. else go to er
  297. else if car x eq 'accent then
  298. if flagp(cadr x,'accdef)
  299. then put(at,'accent,incompe3('!\,cadr x,'!{))
  300. else go to er
  301. else go to er;
  302. if cdr u then go to a;
  303. return nil;
  304. er:lprie(" Syntax error ")
  305. end;
  306. put('defid,'stat,'rlis);
  307. symbolic procedure incompe3(a,b,c);
  308. % Constructs new atom by concatenating A,B,C
  309. intern compress append(explode a,append(explode b,explode c));
  310. symbolic procedure testchar1 u;
  311. % Checks if id U has only one character
  312. if fixp u then u
  313. else if null cdr explode2 u then u
  314. else if member(u,nochar!*) then u
  315. else if member(u,nochar1!*) then u
  316. else <<nochar1!*:=u . nochar1!*; u>>;
  317. procedure chundexp u;
  318. % Replaces underscores _ in ids by \_
  319. % except if u = !_
  320. begin
  321. scalar x;
  322. u:=explode2 u;
  323. x:=u;
  324. if eqcar(u,'_) and cdr u then u:='!\ . u;
  325. a:if null cdr x then goto r;
  326. if cadr x eq '_ then
  327. <<rplacd(x,'!\ . cdr x);
  328. x:=cdr x>>;
  329. x:=cdr x;
  330. goto a;
  331. r:return u
  332. end;
  333. symbolic procedure inprinla(op,p,l);
  334. % Prints infix operator OP with arguments in the list L
  335. begin
  336. if get(op,'alt) then go to a;
  337. maprintla(car l,p);
  338. a0:l:=cdr l;
  339. a:if null l then return nil
  340. else if atom car l or not(op eq get!*(caar l,'alt)) then
  341. <<oprinla op;
  342. maprintla(negnumberchk car l,p)>>
  343. else maprintla(car l,p);
  344. go to a0;
  345. end;
  346. symbolic procedure oprinla op;
  347. % Prints operator OP
  348. begin
  349. scalar x;
  350. if x:=get(op,'lapr) then prin2la x
  351. else if x:=get(op,'prtch) then prin2la x
  352. else if x:=get(op,'lapop) then <<prin2la x; prin2la '! >>
  353. else prinlatom op
  354. end;
  355. % Definition of new operator of division --> horizontal division line
  356. newtok '((!\) backslash);
  357. deflist('((backslash recip)),'unary);
  358. algebraic infix \;
  359. precedence 'backslash,'quotient;
  360. put('backslash,'simpfn,'simpiden);
  361. symbolic procedure prin2la u;
  362. % Prints atom or string U, checks the length of line
  363. % CHUNDEXP makes the change _ -> \_
  364. begin
  365. scalar l;
  366. u:=chundexp u;
  367. l:=length u;
  368. if ncharspr!* + l > laline!* then <<terpri(); ncharspr!*:=0 >>;
  369. for each a in u do prin2 a;
  370. ncharspr!*:=ncharspr!* + l
  371. end;
  372. symbolic procedure prinfrac(l,p);
  373. % Prints the fraction with horizontal division line
  374. <<prin2la "\frac{";
  375. maprintla(car l,0);
  376. prin2la "}{";
  377. maprintla(cadr l,0);
  378. prin2la "}" >>;
  379. put('backslash,'laprifn,'prinfrac);
  380. symbolic procedure defindex u;
  381. % Defines the placing of indices of an operator
  382. for each a in u do defindex1 a;
  383. put('defindex,'stat,'rlis);
  384. symbolic procedure defindex1 u;
  385. begin
  386. scalar at,x;
  387. at:=car u;
  388. for each a in cdr u do if not a memq '(arg up down leftup leftdown)
  389. then x:=t;
  390. if not atom at or null cdr u then x:=t;
  391. return if x then msgpri(" Syntax error ",u,nil,nil,'hold)
  392. else put(at,'indexed,cdr u)
  393. end;
  394. symbolic procedure prinidop(op,args,mask);
  395. % Prints operator with indices. MASK describe the place of indices
  396. begin
  397. scalar arg,up,down,lup,ldown;
  398. if null args then return prinlatom op;
  399. a:if car mask eq 'arg then arg:=car args . arg
  400. else if car mask eq 'up then up:=car args . up
  401. else if car mask eq 'down then down:=car args . down
  402. else if car mask eq 'leftup then lup:=car args . lup
  403. else if car mask eq 'leftdown then ldown:=car args . ldown;
  404. mask:=cdr mask;
  405. args:=cdr args;
  406. if mask and args then go to a;
  407. mask:='(arg);
  408. if args then go to a;
  409. arg:=reverse arg;
  410. up:=reverse up;
  411. down:=reverse down;
  412. lup:=reverse lup;
  413. ldown:=reverse ldown;
  414. if lup or ldown then prin2la "\:";
  415. if lup then
  416. <<prin2la '!^!{;
  417. prinindexs lup;
  418. prin2la "}" >>;
  419. if ldown then
  420. <<prin2la "_";
  421. prin2la "{";
  422. prinindexs ldown;
  423. prin2la "}" >>;
  424. oprinla op;
  425. if up then
  426. <<prin2la '!^!{;
  427. prinindexs up;
  428. prin2la "}" >>;
  429. if down then
  430. <<prin2la "_";
  431. prin2la "{";
  432. prinindexs down;
  433. prin2la "}" >>;
  434. if arg then
  435. <<prinlatom '!(;
  436. inprinla('!*comma!*,0,arg);
  437. prinlatom '!) >>;
  438. return op
  439. end;
  440. symbolic procedure prinindexs ndxs;
  441. % Prints indexces NDXS, if all indices are atoms prints them withouth
  442. % separating commas
  443. begin
  444. scalar b;
  445. for each a in ndxs do if not atom a then b:=t;
  446. if not b then for each a in ndxs do prinlatom a
  447. else inprinla('!*comma!*,0,ndxs)
  448. end;
  449. symbolic procedure exptprla(args,p);
  450. % Prints powers
  451. begin
  452. scalar arg,exp,ilist;
  453. arg:=car args;
  454. exp:=cadr args;
  455. if not atom exp and car exp eq 'quotient and cadr exp = 1
  456. and atom caddr exp
  457. then if caddr exp = 2 then
  458. <<prin2la "\sqrt{";
  459. maprintla(arg,0);
  460. prin2la "}" >>
  461. else
  462. <<prin2la "\sqrt[";
  463. prinlatom caddr exp;
  464. prin2la "]{";
  465. maprintla(arg,0);
  466. prin2la "}" >>
  467. else if atom arg then
  468. <<prinlatom arg;
  469. prin2la '!^!{;
  470. maprintla(exp,0);
  471. prin2la "}" >>
  472. else if atom car arg and not (ilist:=get(car arg,'indexed)) and
  473. not get(car arg,'laprifn) and
  474. not get(car arg,'infix) and atom exp then
  475. <<oprinla car arg;
  476. prin2la '!^!{;
  477. prinlatom exp;
  478. prin2la "}";
  479. prinpopargs(car arg,cdr arg,p) >>
  480. else if atom car arg and (ilist:=get(car arg,'indexed)) and
  481. not memq('up,ilist) then
  482. <<maprintla(arg,0);
  483. prin2la '!^!{;
  484. maprintla(exp,0);
  485. prin2la '!} >>
  486. else
  487. <<prinlatom '!(;
  488. maprintla(arg,0);
  489. prinlatom '!);
  490. prin2la '!^!{;
  491. maprintla(exp,0);
  492. prin2la "}" >>;
  493. return args
  494. end;
  495. put('expt,'laprifn,'exptprla);
  496. procedure sqrtprla(arg,p);
  497. % Prints square root
  498. <<prin2la "\sqrt {";
  499. maprintla(car arg,0);
  500. prin2la "}" >>;
  501. put('sqrt,'laprifn,'sqrtprla);
  502. symbolic procedure intprla(args,p);
  503. % Prints indefinite itegral
  504. begin
  505. scalar arg,var;
  506. if null args or null cdr args or not atom cadr args
  507. then return 'failed;
  508. arg:=car args;
  509. var:=cadr args;
  510. prin2la "\int ";
  511. maprintla(arg,0);
  512. prin2la "\:d\,";
  513. prinlatom var;
  514. return args
  515. end;
  516. put('int,'laprifn,'intprla);
  517. symbolic procedure dintprla(args,p);
  518. % Prints definite integral
  519. begin
  520. scalar down,up,arg,var;
  521. if null args or null cdr args or null cddr args or null cdddr args or
  522. not atom (var:=cadddr args) then return 'failed;
  523. down:=car args;
  524. up:=cadr args;
  525. arg:=caddr args;
  526. prin2la "\int";
  527. prin2la "_";
  528. prin2la "{";
  529. maprintla(down,0);
  530. prin2la "}^{";
  531. maprintla(up,0);
  532. prin2la "}";
  533. maprintla(arg,0);
  534. prin2la "\:d\,";
  535. prinlatom var;
  536. return args
  537. end;
  538. put('dint,'laprifn,'dintprla);
  539. symbolic procedure sumprla(ex,p);
  540. % Prints a sum
  541. begin
  542. scalar op,down,up,arg;
  543. if not get(op:=car ex,'lapop) or null cdr ex or null cddr ex
  544. or null cdddr ex
  545. then return 'failed;
  546. down:=cadr ex;
  547. up:=caddr ex;
  548. arg:=cadddr ex;
  549. oprinla op;
  550. if down then
  551. <<prin2la "_";
  552. prin2la "{";
  553. maprintla(down,0);
  554. prin2la "}" >>;
  555. if up then
  556. <<prin2la '!^!{;
  557. maprintla(up,0);
  558. prin2la "}" >>;
  559. maprintla(arg,get('times,'infix) - 1);
  560. return ex
  561. end;
  562. put('sum,'laprifn,'sumprla);
  563. put('product,'laprifn,'sumprla);
  564. flag('(sum product),'fulla);
  565. symbolic procedure sqprla(args,p);
  566. % Prints standard quotient
  567. maprintla(prepsq!* car args,p);
  568. put('!*sq,'laprifn,'sqprla);
  569. symbolic procedure dfprla(dfex,p);
  570. % Prints derivaves
  571. begin
  572. scalar op,ord,arg,x,argup;
  573. op:=get(car dfex,'lapop);
  574. arg:=cadr dfex;
  575. dfex:=cddr dfex;
  576. x:=dfex;
  577. ord:=0;
  578. a:if null cdr x then
  579. <<x:=cdr x;
  580. ord:=ord+1 >>
  581. else if fixp cadr x then
  582. <<ord:=ord+cadr x;
  583. x:=cddr x >>
  584. else
  585. <<x:=cdr x;
  586. ord:=ord+1 >>;
  587. if x then go to a;
  588. if atom arg or (not get(car arg,'infix) and not get(car arg,'laprifn))
  589. then argup:=t;
  590. prin2la "\frac{";
  591. prin2la op;
  592. if ord=1 then prin2la "\,"
  593. else
  594. <<prin2la '!^!{;
  595. prin2la ord;
  596. prin2la "}" >>;
  597. if argup then maprintla(arg,0);
  598. prin2la "}{";
  599. x:=dfex;
  600. b:if not atom car x and cdr x and fixp cadr x then prin2la "(";
  601. prin2la op;
  602. if null cdr x or not fixp cadr x then
  603. <<prin2la "\,";
  604. maprintla(car x,0);
  605. x:=cdr x >>
  606. else
  607. <<maprintla(car x,0);
  608. if not atom car x then prin2la ")";
  609. prin2la '!^!{;
  610. prin2la cadr x;
  611. prin2la "}";
  612. x:=cddr x >>;
  613. if x then go to b;
  614. prin2la "}";
  615. if null argup then maprintla(arg,get('quotient,'infix));
  616. return arg
  617. end;
  618. put('df,'laprifn,'dfprla);
  619. put('pdf,'laprifn,'dfprla);
  620. flag('(df pdf),'fulla);
  621. put('df,'lapop,"{\rm d}");
  622. put('pdf,'lapop,"\partial ");
  623. procedure listprla(args,p);
  624. % Prints list of expressions
  625. if args then
  626. <<prin2t "\left\{";
  627. maprintla(car args,0);
  628. args:=cdr args;
  629. if args then
  630. for each a in args do
  631. <<prin2la" , ";
  632. maprintla(a,0)>>;
  633. terpri();
  634. prin2 "\right\}">>
  635. else prin2 "\{\}";
  636. put('list,'laprifn,'listprla);
  637. put('arbint,'indexed,'(down));
  638. put('arbreal,'indexed,'(down));
  639. put('arbcomplex,'indexed,'(down));
  640. algebraic;
  641. operator pdf,dint,product;
  642. endmodule;
  643. on echo;
  644. end;