grgmain.sl 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585
  1. %==========================================================================%
  2. % GRGmain.sl Main GRG Functions %
  3. %==========================================================================%
  4. % GRG 3.2 Standard Lisp Source Code (C) 1988-2000 Vadim V. Zhytnikov %
  5. %==========================================================================%
  6. % This file is distributed without any warranty. You may modify it but you %
  7. % are not allowed to remove author's name and/or distribute modified file. %
  8. %==========================================================================%
  9. %------- Reduce Entry Points used in GRG --------------------------------
  10. %
  11. % reval aeval
  12. %
  13. % writepri : varpri - Reduce 3.3, 3.4, 3.4.1, 3.5
  14. % assgnpri - Reduce 3.6, 3.7
  15. %
  16. % on off !~on !~off
  17. %
  18. % operator remopr depend nodepend
  19. %
  20. % order factor remfac
  21. %
  22. % forall !~let let match !~clear clear let00 match00
  23. %
  24. % seprp printprompt
  25. %
  26. %-------------------------------------------------------------------------
  27. %----- Main Function and Sturtup Procedures ------------------------------
  28. % Really Main function. Just puts GRG> into ERRORSET ...
  29. (de grg nil (errorset '(grg!>) nil nil))
  30. %(de grg nil (grg!>)) % May be helpful for debuggin ...
  31. (de grg!> nil
  32. (proc (w wtasknum)
  33. (setq wtasknum 0)
  34. % Banner ...
  35. (terpri) (prin2 ![version!]) (terpri)(terpri)
  36. % Initial settings which can be overridden later in `grg.cfg' ...
  37. (setq !*gc nil)
  38. (setq !*raise nil)
  39. (setq ![origlower!] !*lower)
  40. (setq !*lower nil)
  41. (setq ![lower!] (islowercase!>))
  42. (setq ![fldtuned!] nil)
  43. (setq ![erst1!] nil)
  44. (setq ![erst2!] nil)
  45. (cond ((null ![wf!])
  46. (setq ![wf!] '(!a !b !c !d !e !f !g !h))
  47. (setq ![wi!] '(!i !j !k !l !m !n !o !p !q))
  48. (setq ![wh!] '(!x !y !z !u !v !w !r !s !t))
  49. (setq ![ws!] '(!A !B !C !D !E !F !G !H !M !N !P !Q))
  50. (makeloop!> ![wf!])
  51. (makeloop!> ![wh!])
  52. (makeloop!> ![wi!])
  53. (makeloop!> ![ws!]) ))
  54. (tuneos!>) % trying set [dirsep] and [syscall]
  55. % First Init of GRG switches ...
  56. (initflags!>)
  57. % Trying to get standard input directory from environment ...
  58. (cond ((getd 'getenv) (progn
  59. (setq w (errorset '(getenv "grg") nil nil))
  60. (cond ((equal w '(nil)) (setq w (errorset '(getenv "GRG") nil nil))))
  61. (cond ((atom w) (setq w nil))
  62. (t (setq ![grgdir!] (cdr (reverse (explode
  63. (setq ![grgdir1!] (car w)))))))))))
  64. (cond ((and ![dirsep!] ![grgdir!])
  65. (setq ![grgdir!] (cons ![dirsep!] ![grgdir!]))))
  66. (cond (![grgdir1!] (progn
  67. (prin2 "System directory: ")
  68. (prin2 ![grgdir1!]) (terpri))))
  69. % Input `grg.cfg' file ...
  70. (ingrgsys!>)
  71. (setq ![flaghis!] nil)
  72. (saveflago!>)
  73. % Initial Settings Printing ...
  74. (showcase!>)
  75. (sdimsgn!>)
  76. % Absolute initial settings after `grg.cfg' ...
  77. (setq ![ttime!] (time)) % Overall time
  78. (setq ![tgctime!] (gctime)) % GC time
  79. (setq ![dim0!] ![dim!])
  80. (setq ![sgn0!] ![sgn!])
  81. (initial0!>)
  82. % Main Loop ...
  83. (loop!>
  84. (terpri)
  85. (cond ((eqn wtasknum 0) (setq w '!1))
  86. (t (setq w (asker!>
  87. '(
  88. " Quit GRG - 0"
  89. " Start Task - 1"
  90. " Exit to REDUCE - 2"
  91. )
  92. '( !0 !1 !2 ) ))
  93. (terpri) ))
  94. (setq promptstring!* "<- ")
  95. (cond ((iscsl!>) (setpchar promptstring!*)))
  96. (xrprompt!>)
  97. (setq wtasknum (add1 wtasknum))
  98. (setq w (cond
  99. ((eq w '!0) '(grgquit!>))
  100. ((eq w '!1) '(proceed!>))
  101. ((eq w '!2) '(grgexit!>))
  102. (t nil)))
  103. (cond (w (progn
  104. (setq w (errorset!> w ![erst1!] ![erst2!]))
  105. (cond
  106. ((atom w) (progn (terpri) (erm!> w) (terpri)))
  107. ((equal w '(!!exit!!)) (return nil))
  108. )))))))
  109. (de xrprompt!> nil
  110. (cond ((or (getd 'x!-pr!!) (getenv "redfront"))
  111. (setq promptstring!* (compress
  112. (append
  113. (list2 '!" (int2id 1))
  114. (append
  115. (reverse (cdr (reverse (cdr (explode promptstring!*)))))
  116. (list2 (int2id 2) '!"))))))))
  117. % In `grg.cfg' file ...
  118. (de ingrgsys!> nil
  119. (prog (w cn)
  120. (setq !*lower t)
  121. (setq !*raise t)
  122. (setq cn (grgopeninput!> "grg.cfg"))
  123. (cond ((atom cn)
  124. (setq !*lower nil)
  125. (setq !*raise nil)
  126. (return nil)))
  127. (rds (car cn))
  128. lab1
  129. (setq w (errorset '(read) nil nil))
  130. (cond ((atom w) (progn (erm!> 8802) (go lab2))))
  131. (cond ((equal w '(nil)) (go lab2)))
  132. (setq w (errorset (car w) nil nil))
  133. (cond ((atom w) (progn (erm!> 8802) (go lab2))))
  134. (go lab1)
  135. lab2
  136. (rds nil)
  137. (close (car cn))
  138. (setq !*lower nil)
  139. (setq !*raise nil)
  140. ))
  141. % First init of switches in the session ...
  142. (de initflags!> nil
  143. (progn
  144. (gprinreset!>)
  145. (cond
  146. ((and (fancyexist!>) (fancyloaded!>) (fancyon!>))
  147. (tunefancy!> t)))
  148. (cond
  149. ((and (getd 'x!-pr!!) (fancyexist!>))
  150. (on0!> '(fancy))))
  151. (setq ![flaghis!] nil)
  152. (foreach!> x in ![flagnil!] do (set x nil))
  153. (foreach!> x in ![flagt!] do (set x t))
  154. ))
  155. % Saves the initial setting of output mode switch ...
  156. (de saveflago!> nil
  157. (prog (w)
  158. (setq w (cond
  159. (!*latex 'latex )
  160. ((fancyon!>) 'fancy )
  161. (!*grg 'grg )
  162. (!*reduce 'reduce )
  163. (!*maple 'maple )
  164. (!*math 'math )
  165. (!*macsyma 'macsyma ) ))
  166. (setq ![iflago!] w)))
  167. %----- Main Loop ---------------------------------------------------------
  168. % Start new Task ...
  169. (de proceed!> nil
  170. (progn
  171. (initial0!>)
  172. (rund!>) ))
  173. % Continue old Task ...
  174. (de continue!> nil
  175. (prog2
  176. (setq ![er!] nil)
  177. (rund!>)))
  178. %----- Some General Commands ---------------------------------------------
  179. (de copyrzw!> nil
  180. (progn
  181. (terpri)
  182. (prin2 ![version!]) (terpri)
  183. (prin2 "(C) 1988-96 Vadim V. Zhytnikov ")
  184. (terpri) (terpri)))
  185. % The System ; command.
  186. % Temporary exit to OS ...
  187. (de grgsystem!> (lst)
  188. (cond
  189. ((null lst) % System;
  190. (cond
  191. ((eqn ![syscall!] 1) % Via system ...
  192. (progn
  193. (setq lst (errorset '(system) nil nil))
  194. (cond ((atom lst) (prog2 (setq ![er!] 1104) !!er!!)))))
  195. ((eqn ![syscall!] 2) % via quit ...
  196. (quit))
  197. (t (msg!> 1102)))) % Not supported
  198. ((and (stringp(car lst)) (null(cdr lst))) % System "...";
  199. (cond
  200. ((or (eqn ![syscall!] 1) (eqn ![syscall!] 2)) % Trying system ...
  201. (progn
  202. (setq lst (errorset (list 'system (car lst)) nil nil))
  203. (cond ((atom lst) (prog2 (setq ![er!] 1104) !!er!!)))))
  204. (t (msg!> 1102)))) % Not supported
  205. (t (prog2 (setq ![er!] 1103) !!er!!))))
  206. % The Quit; Command and related operations ...
  207. (de grgquit!> nil
  208. (progn
  209. (closeunload!>)
  210. (grgstat!>)
  211. (closewrite!>)
  212. (bye) ))
  213. (de grgexit!> nil
  214. (prog nil
  215. (closeunload!>)
  216. (grgstat!>)
  217. (closewrite!>)
  218. (setq !*raise t)
  219. (setq !*lower ![origlower!])
  220. (prin2 "Exiting. Type ``grg;'' to restart GRG ...")(terpri)
  221. (return '!!exit!!)
  222. ))
  223. % Statistics printing ...
  224. (de grgstat!> nil
  225. (prog (wt wgt)
  226. (setq wt (difference (time) ![ttime!]))
  227. (setq wgt (difference (gctime) ![tgctime!]))
  228. (cond ((iscsl!>) (setq wt (plus wt wgt))))
  229. (cond ((not(eqn wt 0)) (setq wgt (quotient (times 100 wgt) wt)))
  230. (t (setq wgt 0)))
  231. (terpri)
  232. (prin2 "Overall Session time: ")
  233. (prtime!> wt)
  234. (cond ((zerop wt) (prog2 (terpri) (return nil))))
  235. (prin2 " (")
  236. (prin2 wgt)
  237. (prin2 "%GC)")
  238. (terpri)))
  239. %------ Messages -------------------------------------------------------
  240. % Error messages ...
  241. (de erm!> (w)
  242. (proc (lst wm)
  243. (cond ((null w) (return nil)))
  244. (closewrite!>)
  245. (setq lst '(
  246. (1000 . "ERROR: User interrupt.")
  247. (1100 . "ERROR: Incorrect parameter of the command.")
  248. (1101 . "ERROR: Coordinates already exist.")
  249. (1103 . "ERROR: String is expected as a parameter.")
  250. (1104 . "ERROR: Command failed.")
  251. (2001 . "ERROR: Missing parameter or closing bracket in [,].")
  252. (2002 . "ERROR: First parameter of _| must be a vector.")
  253. (2003 . "ERROR: Second parameter of _| must be a form.")
  254. (20021 . "ERROR: First parameter of | must be a vector.")
  255. (20031 . "ERROR: Second parameter of | must be a scalar.")
  256. (2004 . "ERROR: Exterior differential of a vector is impossible.")
  257. (2005 . "ERROR: Parameters of /\ must be exterior forms.")
  258. (2006 . "ERROR: Parameters of [,] must be vectors.")
  259. (2007 . "ERROR: Dualization of a vector is impossible.")
  260. (2008 . "ERROR: Form or vector is invalid in ^.")
  261. (2009 . "ERROR: Zero denominator.")
  262. (2010 . "ERROR: At lest one parameter of * must be a scalar.")
  263. (2011 . "ERROR: Division on form or vector is impossible.")
  264. (2012 . "ERROR: Terms of different type in A+B or A-B.")
  265. (2013 . "ERROR: X must be a coordinate in @ X.")
  266. (2014 . "ERROR: Missing operation.")
  267. (2015 . "ERROR: Missing parameter of unary operation.")
  268. (2016 . "ERROR: Missing parameter of operation.")
  269. (2017 . "ERROR: Missing summand.")
  270. (2018 . "ERROR: Unrecognized identifier.")
  271. (20181 . "ERROR: Unrecognized variable.")
  272. (2019 . "ERROR: String in expression.")
  273. (2020 . "ERROR: Incorrect parameters list.")
  274. (2021 . "ERROR: Incorrect function or missing operation.")
  275. (2022 . "ERROR: Unrecognized function.")
  276. (2023 . "ERROR: Form or vector as an argument of function is invalid.")
  277. (20231 . "ERROR: Form or vector valued index is invalid.")
  278. (2030 . "ERROR: Vector or 1-form are expected in scalar product.")
  279. (2100 . "ERROR: Wrong type of expression.")
  280. (2101 . "ERROR: Wrong identifier of object.")
  281. (2102 . "ERROR: Incorrect indices.")
  282. (21022 . "ERROR: Index out of range.")
  283. (21023 . "ERROR: Number of indices is less than expected.")
  284. (21024 . "ERROR: Number of indices is more than expected.")
  285. (2103 . "ERROR: Incorrect Sum() or Prod() expression.")
  286. (21031 . "ERROR: Wrong iteration variable specification.")
  287. (2104 . "ERROR: Strange variable.")
  288. (2105 . "ERROR: Wrong number of parameters.")
  289. (2106 . "ERROR: Wrong parameter's value.")
  290. (2108 . "ERROR: Incorrect min or max in iteration specification.")
  291. (2110 . "ERROR: ~~ can be used as expr+~~ or expr-~~ only.")
  292. (2113 . "ERROR: No Solutions are defined.")
  293. (2114 . "ERROR: There is no Solution with this number.")
  294. (2115 . "ERROR: 0 = 0 relation is invalid here.")
  295. (2200 . "ERROR: Incorrect tensorial assignment.")
  296. (2201 . "ERROR: Incorrect Coordinates or Constants declaration.")
  297. (2202 . "ERROR: Wrong commas.")
  298. (2203 . "ERROR: Coordinates does not match Dimension.")
  299. (2204 . "ERROR: Incorrect assignment.")
  300. (2205 . "ERROR: Repeated index in LHS.")
  301. (2206 . "ERROR: Incorrect indices in tensorial assignment.")
  302. (2207 . "ERROR: Wrong number of indices.")
  303. (22071 . "ERROR: Unrecognized object.")
  304. (2208 . "ERROR: Equation is expected at RHS.")
  305. (2209 . "ERROR: Types of RHS and LHS differ.")
  306. (2300 . "ERROR: Incorrect Solve command.")
  307. (2301 . "ERROR: Solve failed.")
  308. (2303 . "ERROR: Non equation in Solve.")
  309. (2304 . "ERROR: Empty or trivial equations in Solve.")
  310. (2400 . "ERROR: Incorrect boolean expression.")
  311. (2410 . "ERROR: Unknown object name.")
  312. (2420 . "ERROR: Unknown switch.")
  313. (2500 . "ERROR: Incorrect Lie derivative.")
  314. (2501 . "ERROR: Vector is expected in Lie derivative.")
  315. (2502 . "ERROR: Cannot calculate Lie derivative of noncovariant object.")
  316. (2600 . "ERROR: Incorrect covariant differential Dc.")
  317. (2602 . "ERROR: Cannot calculate Dc of noncovariant object.")
  318. (2603 . "ERROR: Wrong specification of alternative connection in Dc.")
  319. (2700 . "ERROR: Incorrect covariant derivative Dfc.")
  320. (2701 . "ERROR: Vector is expected in covariant derivative.")
  321. (2702 . "ERROR: Cannot calculate Dfc of noncovariant object.")
  322. (2703 . "ERROR: Wrong specification of alternative connection in Dfc.")
  323. (2704 . "ERROR: Dfc of form or vector is impossible.")
  324. (3000 . "ERROR: Object already exists.")
  325. (3001 . "ERROR: Wrong type of indices for connection 1-form.")
  326. (3002 . "ERROR: Connection must be 1-form valued.")
  327. (4000 . "ERROR: Zero volume element.")
  328. (4001 . "ERROR: Rotation Matrix isn't specified.")
  329. (5012 . "ERROR: Incorrect Functions declaration.")
  330. (5013 . "ERROR: Identifier already used.")
  331. (50130 . "ERROR: This Identifier can't be used in GRG.")
  332. (5016 . "ERROR: Incorrect function dependence list.")
  333. (5100 . "ERROR: Generic Functions are not supported.")
  334. (5101 . "ERROR: Incorrect Generic Function declaration.")
  335. (6030 . "ERROR: Unrecognized object.")
  336. (6042 . "ERROR: Incorrect command.")
  337. (6043 . "ERROR: Unrecognized way of calculation.")
  338. (6044 . "ERROR: Incorrect compound command structure.")
  339. (6046 . "ERROR: Too few data.")
  340. (6100 . "ERROR: Bad bracket count.")
  341. (6200 . "ERROR: Incorrect Asy/Sy/Cy expression.")
  342. %(6201 . "ERROR: Limits does not supported.")
  343. %(6202 . "ERROR: Incorrect Limit expression.")
  344. %(6203 . "ERROR: Form or Vector as a limiting point in Lim.")
  345. (6204 . "ERROR: Incorrect SUB() expression.")
  346. (6205 . "ERROR: Form or Vector in SUB().")
  347. (6301 . "ERROR: Incorrect file name.")
  348. (6321 . "ERROR: Can't open the file.")
  349. (6402 . "ERROR: Unrecognized switch.")
  350. (6500 . "ERROR: On TORSION is required.")
  351. (6501 . "ERROR: On NONMETR is required.")
  352. (6502 . "ERROR: On TORSION and On NONMETR is required.")
  353. (6503 . "ERROR: On TORSION or On NONMETR is required.")
  354. (6504 . "ERROR: Off NONMETR is required.")
  355. (6505 . "ERROR: Off TORSION is required.")
  356. (6506 . "ERROR: Off TORSION and Off NONMETR is required.")
  357. (65002 . "ERROR: dim>2 is required.")
  358. (650022 . "ERROR: dim=2 is required.")
  359. (65003 . "ERROR: dim>3 is required.")
  360. (65004 . "ERROR: dim>4 is required.")
  361. (65005 . "ERROR: dim>5 is required.")
  362. (6702 . "ERROR: Velocity is null.")
  363. (6800 . "ERROR: Singular Metric or Inverse Metric.")
  364. (6802 . "ERROR: Singular Frame or Vector Frame.")
  365. (7200 . "ERROR: The file has format unknown for Load/Show.")
  366. (7301 . "ERROR: Please specify Coordinates first.")
  367. (7302 . "ERROR: Please specify Affine Parameter first.")
  368. (7720 . "ERROR: File contains erroneous data.")
  369. (7804 . "ERROR: Standard null metric is required for spinors.")
  370. (78040 . "ERROR: dim=4 is required for spinors.")
  371. (78041 . "ERROR: Standard null metric is required for spinorial rotation.")
  372. (7805 . "ERROR: dim=4 is required.")
  373. (7806 . "ERROR: Default diagonal metric is required.")
  374. (7900 . "ERROR: The file contains other Dimension and/or Signature.")
  375. (7910 . "ERROR: Signature -,+,+,+ or +,-,-,- is required for Null Metric.")
  376. (8100 . "ERROR: Bad package name.")
  377. (8102 . "ERROR: Cannot load the package.")
  378. (8200 . "ERROR: Incorrect If( ) expression.")
  379. (8201 . "ERROR: Non numeric argument in a relation.")
  380. (8375 . "ERROR: Incorrect New Coordinates declaration.")
  381. (8377 . "ERROR: Singular coordinates transformation.")
  382. (8389 . "ERROR: Form or vector in old coordinates dependence list.")
  383. (8388 . "ERROR: Recursive old coordinates dependence.")
  384. (8400 . "ERROR: Singular Basis.")
  385. (8401 . "ERROR: Singular Vector Basis.")
  386. (8500 . "ERROR: Incorrect matrix.")
  387. (8501 . "ERROR: The matrix isn't spinorial rotation.")
  388. (8502 . "ERROR: The matrix isn't frame rotation.")
  389. (8504 . "ERROR: Singular Matrix.")
  390. (8600 . "ERROR: Incorrect New Object declaration.")
  391. (8601 . "ERROR: Wrong type specification in the declaration.")
  392. (8602 . "ERROR: Wrong indices specification in the declaration.")
  393. (8604 . "ERROR: Identifier of new object contains digits or ~.")
  394. (8606 . "ERROR: Wrong symmetry specification.")
  395. (8709 . "ERROR: Incorrect Let command.")
  396. (8710 . "ERROR: Zero is invalid in Let or Clear.")
  397. (8711 . "ERROR: Form or vector in Let or Clear.")
  398. (8712 . "ERROR: Incorrect For All command.")
  399. (8713 . "ERROR: Incorrect For All command.")
  400. (8714 . "ERROR: Incorrect parameters list in For All.")
  401. (8800 . "ERROR: Dimension must be 2 or greater.")
  402. (8801 . "ERROR: Dimension does not match Signature.")
  403. (88011 . "ERROR: Incorrect Dimension declaration.")
  404. (88012 . "ERROR: Dimension declaration must be first in session.")
  405. (8802 . "ERROR: Incorrect data in the `grg.cfg' file.")
  406. (8803 . "ERROR: Transformation was not properly completed.")
  407. (9002 . "ERROR: Incorrect Signature in `grg.cfg' file.")
  408. (9100 . "ERROR: Cannot classify form of vector.")
  409. (9101 . "ERROR: Do not know how to classify this object.")
  410. (9602 . "ERROR: Double ; delimiter.")
  411. (9901 . "ERROR: Unexpected end of file.")
  412. (9913 . "ERROR: Can't transform spinorial index to holonomic.")
  413. (9999 . "ERROR: Cannot handle *SQ form in the expression.")
  414. )) (while!> lst
  415. (cond ((eqn w (caar lst)) (setq wm (cdar lst))))
  416. (setq lst (cdr lst)))
  417. (cond (wm (prin2 wm) (terpri))
  418. (t (prin2 "ERROR: ") (prin2 w) (terpri)
  419. (lowmemwarn!>) ))
  420. % If Batch mode then quitting ...
  421. (cond (!*batch
  422. (prinN2 "GRG is in Batch mode. Quitting ...")
  423. (terpri)
  424. (grgquit!>)))
  425. ))
  426. % Messages ...
  427. (de msg!> (w)
  428. (proc (lst wm)
  429. (cond ((null w) (return nil)))
  430. (setq lst '(
  431. (100 . "WARNING: Macro tensor is not allowed in Find command.")
  432. (1102 . "Command System; is not supported.")
  433. (2104 . "WARNING: min > max in iteration.")
  434. (2109 . "WARNING: Summation or iteration variable is already in use.")
  435. (2112 . "WARNING: Manipulation with enumerating index is ignored.")
  436. (2302 . "WARNING: No solutions found.")
  437. (50131 . "WARNING: This Function can be used without declaration.")
  438. (6700 . "WARNING: Null congruence is not actually null.")
  439. (6701 . "WARNING: Null congruence is not geodesic.")
  440. (6702 . "WARNING: Frenkel condition is not satisfied.")
  441. (6801 . "Assuming Default Metric.")
  442. (6803 . "Assuming Default Holonomic Frame.")
  443. (6805 . "Assuming Default comoving Velocity.")
  444. (6820 . "WARNING: Metric already exists.")
  445. (7012 . "Basis can not be erased in anholonomic mode.")
  446. (7630 . "WARNING: Coordinates have been redefined.")
  447. (7631 . "WARNING: Loaded constants conflict with coordinates.")
  448. (7632 . "WARNING: Loaded constants conflict with functions.")
  449. (7633 . "WARNING: Loaded functions conflict with coordinates.")
  450. (7634 . "WARNING: Loaded functions conflict with constants.")
  451. (7635 . "WARNING: Loaded coordinates conflict with constants.")
  452. (7637 . "WARNING: Loaded coordinates conflict with functions.")
  453. (8101 . "WARNING: Package already loaded.")
  454. (8391 . "Keeping Frame holonomic.")
  455. (8392 . "Keeping Vector Frame holonomic.")
  456. (8603 . "WARNING: Identifier already used.")
  457. (8607 . "Same indices in different symmetry groups.")
  458. (8701 . "WARNING: Unable to Forget built-in object.")
  459. (88033 . "No guaranty for correct operation of the system. Better quit now!")
  460. (8901 . "Fetching the file from System directory.")
  461. (8902 . "Fetching `grg.cfg' file from System directory.")
  462. (9001 . "WARNING: Velocity is not normalized.")
  463. (9100 . "WARNING: Quite old REDUCE. All letters will be in lower case.")
  464. (9101 . "WARNING: LaTeX output mode is not supported since GRG unable")
  465. (91011 . "WARNING: to load `fmprint' package. Check that you have `fmprint.b'")
  466. (91012 . "WARNING: file and copy it into your current directory or into the")
  467. (91013 . "WARNING: directory where REDUCE usually looks for binary packages")
  468. (91014 . "WARNING: (e.g. `$reduce/fasl/').")
  469. )) (while!> lst
  470. (cond ((eqn w (caar lst)) (setq wm (cdar lst))))
  471. (setq lst (cdr lst)))
  472. (cond (wm (prin2 wm) (terpri))
  473. (t (prin2 "WARNING: ") (prin2 w) (terpri)))
  474. ))
  475. (de doub!> (w)
  476. (progn (closewrite!>)
  477. (prin2 w)
  478. (prin2 " - ? ")
  479. (terpri)))
  480. (de doubs!> (w)
  481. (progn (closewrite!>)
  482. (prin1 w)
  483. (prin2 " - ? ")
  484. (terpri)))
  485. (de doubl!> (lst)
  486. (progn (closewrite!>)
  487. (gprinreset!>)
  488. (gprin!> "`")
  489. (gprinwb!> lst)
  490. (gprin!> "'")(gprin!> " - ?")
  491. (gterpri!>)))
  492. (de doubo!> (wi)
  493. (progn (closewrite!>)
  494. (gprinreset!>)
  495. (gprinwb!> (txt!> wi)) (gprin!> " - ?")
  496. (gterpri!>)))
  497. % Warning about low memory ...
  498. (de lowmemwarn!> nil
  499. (prog (wt wgt)
  500. (setq wt (difference (time) ![time!]))
  501. (setq wgt (difference (gctime) ![gctime!]))
  502. (cond ((iscsl!>) (setq wt (plus wt wgt))))
  503. (cond ((not(eqn wt 0)) (setq wgt (quotient (times 100 wgt) wt)))
  504. (t (setq wgt 0)))
  505. (cond
  506. ((and (lessp wgt 100) (greaterp wgt 39)) (progn
  507. (prin2 "Garbage Collections constitute ")
  508. (prin2 wgt)
  509. (prin2 "% of the total CPU time.")
  510. (terpri)
  511. (cond
  512. ((greaterp wgt 59) (prin2 "ATTENTION: Memory is exhausted!"))
  513. (t (prin2 "WARNING: Free memory is low!")))
  514. (terpri)
  515. )))
  516. ))
  517. %------- Names of Built-In Objects --------------------------------------
  518. % This gives the list - Name of an Object ...
  519. (de txt!> (wi) % wi - internal variable
  520. (proc (w)
  521. (cond ((or (flagp wi '!+abbr) (flagp wi '!+macros2))
  522. (return (idtxt!> wi))))
  523. (setq w ![datl!])
  524. (while!> w
  525. (cond ((eq wi (cadar w)) (return (lowertxt!> (caar w))))
  526. (t (setq w (cdr w)))))))
  527. (de thetxt!> (wi) % wi - internal variable
  528. (proc(w)
  529. (cond ((or (flagp wi '!+abbr) (flagp wi '!+macros2))
  530. (return (cons '!T!h!e (idtxt!> wi))))) % word!!!
  531. (setq w ![datl!])
  532. (while!> w
  533. (cond ((eq wi (cadar w)) (return (lowertxt!> (caar w))))
  534. (t (setq w (cdr w)))))))
  535. (de lowertxt!> (w)
  536. (proc (wr wn)
  537. (while!> w
  538. (cond (wn (setq wr (cons (lowertxt0!> (car w) t) wr)))
  539. (t (setq wr (cons (lowertxt0!> (car w) nil) wr))
  540. (setq wn t)))
  541. (setq w (cdr w)))
  542. (return(reversip wr))))
  543. (de lowertxt0!> (w wc)
  544. (cond ((not(idp w)) w)
  545. ((get w '!=printas) (get w '!=printas))
  546. (t (proc (we wr)
  547. (setq we (explode w))
  548. (while!> we
  549. (cond
  550. ((liter (car we))
  551. (cond (wc (setq wr (cons (tolc!>(car we)) wr)))
  552. (t (setq wr (cons (touc!>(car we)) wr))
  553. (setq wc t))))
  554. (t (setq wr (cons (car we) wr))))
  555. (setq we (cdr we)))
  556. (return(incom!>(reversip wr)))))))
  557. % The name for a new Object created by user ...
  558. (de idtxt!> (wi)
  559. (prog (w)
  560. (setq w (cdr (explode2 wi)))
  561. (return (ncons (incom!> w)))))
  562. % Prints Object's name via GPRIN> ...
  563. (de pn!> (wi) (gprils!> (txt!> wi)))
  564. (de pn0!> (wi) (gprils0!> (txt!> wi)))
  565. (de pn0dot!> (wi) (gprils0dot!> (txt!> wi)))
  566. (de thepn!> (wi) (gprils!> (thetxt!> wi)))
  567. (de thepn0!> (wi) (gprils0!> (thetxt!> wi)))
  568. %------- Functions for manipulation with whole data boxes -----------
  569. % Here: LST - the Box list; WN - internal variable;
  570. % WI - NIL at the beginning, the index list is collected here;
  571. % IDXL - IDXL list at the beginning;
  572. % FUN - function (FUN W WI WN) here
  573. % W - element, WI - its indices, WN - intern. variable
  574. % Apply FUN to each element in the LST ...
  575. (de allcom!> (lst wn wi idxl fun)
  576. (cond((null idxl) (apply fun (list lst (reverse wi) wn)))
  577. (t(proc (wc) (setq wc -1)
  578. (while!> lst
  579. (setq wc (add1 wc))
  580. (allcom!> (car lst) wn (cons wc wi) (cdr idxl) fun)
  581. (setq lst(cdr lst)))))))
  582. % Apply FUN to each element in LST and collect result ...
  583. (de allcoll!> (lst wn wi idxl fun)
  584. (cond((null idxl) (apply fun (list lst (reverse wi) wn)))
  585. (t(proc (wc w) (setq wc -1)
  586. (while!> lst
  587. (setq wc (add1 wc))
  588. (setq w (cons
  589. (allcoll!> (car lst) wn (cons wc wi) (cdr idxl) fun) w))
  590. (setq lst(cdr lst)))
  591. (return (reverse w))
  592. ))))
  593. %--------- Tracing messages ----------------------------------------------
  594. % Sometning has/have been calculated ...
  595. (de trsc!> (w wy)
  596. (cond(!*trace
  597. (prog (wm)
  598. (gprinreset!>)
  599. (setq ![gptab!] 2)
  600. (pn!> w)
  601. (cond
  602. ((null wy)
  603. (gprils0!> (cond
  604. ((flagp w '!+pl) '("calculated."))
  605. (t '("calculated.")) )))
  606. %((flagp w '!+pl) '("have" "been" "calculated."))
  607. %(t '("has" "been" "calculated.")) )))
  608. (t (gprils0!> (cond
  609. ((flagp w '!+pl) '("calculated"))
  610. (t '("calculated")) ))
  611. %((flagp w '!+pl) '("have" "been" "calculated"))
  612. %(t '("has" "been" "calculated")) ))
  613. (cond (wy (gprin!> '! ) (gprils0dot!> (lowertxt!> wy))))))
  614. (gprin!> '! )
  615. (gptime!>)))))
  616. %(de trsc!> (w wy)
  617. % (cond(!*trace
  618. % (progn (gprinreset!>)
  619. % (setq ![gptab!] 2)
  620. % (pn!> w)
  621. % (gprils0!> (cond
  622. % ((flagp w '!+pl) '("have" "been" "calculated"))
  623. % (t '("has" "been" "calculated")) ))
  624. % (cond(wy(prog2 (gprin!> '! ) (gprils0!> (lowertxt!> wy)))))
  625. % (gprin!> ". ")
  626. % (gptime!>)))))
  627. % Done ...
  628. (de done!> nil
  629. (cond(!*trace
  630. (progn (gprinreset!>)
  631. (gprils0!> '("Done: "))
  632. (gptime!>)))))
  633. % Too few data ...
  634. (de tfd!> (w)
  635. (progn (gprinreset!>)
  636. (setq ![gptab!] 2)
  637. (gprils!> '("Too" "few" "data" "for" "calculation" "of"))
  638. %(pn0!> w)(gprin!> ".")(gterpri!>)))
  639. (pn0dot!> w)(gterpri!>)))
  640. % Failed to calculate ...
  641. (de trsf!> (w)
  642. (progn (gprinreset!>)
  643. (setq ![gptab!] 2)
  644. (gprils!> '("Cannot" "calculate"))
  645. %(pn0!> w)(gprin!> ".")(gterpri!>)))
  646. (pn0dot!> w)(gterpri!>)))
  647. % Already exists ...
  648. (de aexp!> (w)
  649. (progn (gprinreset!>)
  650. (setq ![gptab!] 2)
  651. (gprils!> '("Value" "of"))
  652. (pn!> w)
  653. (gprils0!> '("is" "known" "already."))
  654. (gterpri!>)))
  655. % The value indefinite ...
  656. (de abse!> (w)
  657. (progn (gprinreset!>)
  658. (setq ![gptab!] 2)
  659. (gprils!> '("Value" "of"))
  660. (pn!> w)
  661. (gprils0!> '("is" "indefinite."))
  662. (gterpri!>)))
  663. % Something can't be calculated ...
  664. (de cantcalc!> (w)
  665. (progn (gprinreset!>)
  666. (setq ![gptab!] 2)
  667. (thepn!> w)
  668. (gprin!> '("can't" "be" "calculated."))
  669. (gterpri!>)))
  670. % Something can't be calculated by way WY ...
  671. (de cantway!> (w wy)
  672. (progn (gprinreset!>)
  673. (setq ![gptab!] 2)
  674. (thepn!> w)
  675. (gprin!> '("can't" "be" "calculated"))
  676. %(gprils0!> (lowertxt!> wy))(gprin!> ".")(gterpri!>) ))
  677. (gprils0dot!> (lowertxt!> wy))(gterpri!>) ))
  678. %------ Initial Settings for a New Task ----------------------------------
  679. % All system parameters resetting ...
  680. (de initial0!> nil
  681. (progn
  682. (setq ![mtype!] nil)
  683. (setq ![mitype!] nil)
  684. (setq ![dtype!] nil)
  685. (setq ![ditype!] nil)
  686. (setq ![ftype!] nil)
  687. (setq ![fitype!] nil)
  688. (setq ![dim!] ![dim0!])
  689. (setq ![sgn!] ![sgn0!])
  690. (tunedim!>)
  691. (setq ![echo!] nil)
  692. (resetsubs!>) % Reset substitutions (before declarations!) ...
  693. (rempf!> ![rpfl!] '(1 2)) % Clear all declarations ...
  694. (setq ![gfun!] nil)
  695. % Clear all data values ...
  696. (foreach!> x in ![datl!] do
  697. (cond((atom(cadr x)) (prog2
  698. (set (cadr x) nil)
  699. (cond ((flagp (cadr x) '!+abbr) (forget1!>(cadr x))))))))
  700. (foreach!> x in ![abbr!] do
  701. (prog2 (set x nil) (forget1!> x)))
  702. (resetflags!>) % Resetting switches ...
  703. (closeallo!>) % Cloasing all files ...
  704. % Restoring default values of system variables ...
  705. (foreach!> x in
  706. '( ![solveq!] ![er!] ![wri!] ![chain!] ![unl!]
  707. ![pause!] ![fromf!] ![loa!] ![umod!] ![way!]
  708. ![x!] ![ocord!] ![xb!] ![dfx!] ![dex!] ![lsrs!]
  709. ![xv!] ![ccb!] ![xf!] ![ccbi!] ![lwri!] ![lunl!]
  710. ![l!] ![la!] ![li!] ![dbas!] )
  711. do (set x nil))
  712. (setq ![lline!] 0)
  713. (gprinreset!>)
  714. (setq ![time!] (time))
  715. (setq ![gctime!] (gctime))
  716. ))
  717. % This closes really all output files ...
  718. (de closeallo!> nil
  719. (prog2
  720. (closeunload!>)
  721. (closewrite!>) ))
  722. % This closes global Write output ...
  723. (de closewrite!> nil
  724. (progn
  725. (cond(![wri!] (close ![wri!])))
  726. (setq ![wri!] nil)
  727. (wrs nil)))
  728. % This close global Unload ...
  729. (de closeunload!> nil
  730. (progn
  731. (cond(![unl!](progn
  732. (wrs ![unl!])
  733. (print t)
  734. (wrs ![wri!])
  735. (close ![unl!]))))
  736. (setq ![unl!] nil)
  737. ))
  738. % Resets all switches to initial values ...
  739. (de resetflags!> nil
  740. (proc (w ww)
  741. (cond(![iflago!]
  742. (setq ![flaghis!]
  743. (append ![flaghis!]
  744. (ncons(cons ![iflago!] t))))))
  745. (while!> ![flaghis!]
  746. (setq w (car ![flaghis!]))
  747. (setq ww (makeswvar!> (car w)))
  748. (cond((not(equal (eval ww) (cdr w)))
  749. (cond ((flagp (car w) 'switch) % Reduce ...
  750. (cond ((cdr w) (eval (list 'on (car w))))
  751. (t (eval (list 'off (car w)))))
  752. (onoff1!> (car w) (cdr w)))
  753. (t(onoff1!> (car w) (cdr w)))))) % GRG ...
  754. (setq ![flaghis!] (cdr ![flaghis!]))
  755. (cond((null ![iflago!]) (offallo!>)))
  756. )))
  757. % Resets all substitutions ...
  758. (de resetsubs!> nil
  759. (proc (w)
  760. (while!> ![sublist!]
  761. (setq w (car ![sublist!]))
  762. (errorset (list (car w) (list 'quote (cadr w)))
  763. ![erst1!] ![erst2!])
  764. (setq ![sublist!] (cdr ![sublist!])))))
  765. % Removes all Cord, Const and Fun declarations ...
  766. (de rempf!> (lst wt)
  767. (proc (w x)
  768. (cond ((member 2 wt)
  769. (foreach!> xx in ![cord!] do (nodepend (cons xx ![apar!])))))
  770. (cond((member 1 wt)
  771. (foreach!> xx in ![fun!] do (prog2
  772. (cond((setq w(get xx '!=depend))(nodepend w)))
  773. (remopr xx)
  774. )) ))
  775. (while!> lst
  776. (setq x (car lst))
  777. (cond((setq w(eval(caar x)))
  778. (progn
  779. (cond((cadr x)
  780. (foreach!> y in (cadr x) do (remflag w y))))
  781. (cond((cddr x)
  782. (foreach!> y in (cddr x) do
  783. (foreach!> z in w do (remprop z y))))))))
  784. (setq lst(cdr lst)))
  785. ))
  786. %------ Tuning for dimension --------------------------------------------
  787. (de tunedim!> nil
  788. (prog (w wa)
  789. (setq ![dim1!] (sub1 ![dim!]))
  790. (setq ![sigprod!] (sigprod!>))
  791. (put '!d!i!m '!=sysconst ![dim!])
  792. (put '!s!i!g!n '!=sysconst ![sigprod!])
  793. (put '!s!g!n!t '!=sysconst ![sigprod!])
  794. (setq wa (ncons(cons 'a (dimlist1!> 1))))
  795. (put '!#!e!p!s '!=sidxl wa)
  796. (put '!#!e!p!s!i '!=sidxl wa)
  797. (put '!#!e!p!s!h '!=sidxl wa)
  798. (put '!#!e!p!s!i!h '!=sidxl wa)
  799. (put '!#!e!p!s '!=idxl (mks1!> ![dim1!] nil))
  800. (put '!#!e!p!s!i '!=idxl (mks1!> ![dim1!] t))
  801. (put '!#!e!p!s!h '!=idxl (mks1!> ![dim1!] 0))
  802. (put '!#!e!p!s!i!h '!=idxl (mks1!> ![dim1!] 1))
  803. (cond ((eqn ![sigprod!] -1) (put '!#!s!d!e!t!G '!=tex "\sqrt{-g}") )
  804. (t (put '!#!s!d!e!t!G '!=tex "\sqrt{g}") ))
  805. ))
  806. %------ Metric and Frame Type -------------------------------------------
  807. % Determines Frame Type ...
  808. % [FTYPE] NIL - unknown, 1 - holonomic, 2 - diag, 3 - general
  809. (de ftype!> nil (ftype0!> !#!T '![ftype!]))
  810. (de fitype!> nil (ftype0!> !#!D '![fitype!]))
  811. (de ftype0!> (w wt)
  812. (cond
  813. (w (prog (wc wcc wod wnu) % wod - off diag, wnu - non unit
  814. (cond (![umod!] (set wt 3) (return nil)))
  815. (fordim!> i do
  816. (fordim!> j do
  817. (progn
  818. (setq wc (exprtype!>
  819. (setq wcc (getfdx!> (getel1!> w i) j))))
  820. (cond ((and (not(eqn i j)) wc) % off diag
  821. (setq wod t)))
  822. (cond ((and (eqn i j) (not(equal wcc 1))) % not unit
  823. (setq wnu t))
  824. ))))
  825. (cond ((and (null wod) (null wnu)) (set wt 1))
  826. ((null wod) (set wt 2))
  827. ( t (set wt 3)))))
  828. (t (set wt nil))))
  829. % Determines Metric Type ...
  830. % [MTYPE] NIL - unknown, 1 - null, 2 - diag, 3 - general
  831. % [DTYPE] NIL - unknown, 1 - constant, 2 - general
  832. (de mtype!> nil (mtype0!> !#!G '![mtype!] '![dtype!]))
  833. (de mitype!> nil (mtype0!> !#!G!I '![mitype!] '![ditype!]))
  834. (de mtype0!> (w wt wd)
  835. (cond
  836. (w (prog (wc wod wnc) % wod - off diag, wnc - non const
  837. (cond
  838. ((and (equal ![sgn!] '(-1 1 1 1)) (equal w ![nullm!]))
  839. (set wt 1) (set wd 1) (return t))
  840. ((and (equal ![sgn!] '(1 -1 -1 -1)) (equal w ![nullm1!]))
  841. (set wt 1) (set wd 1) (return t)))
  842. (fordim!> i do
  843. (fordim!> j do
  844. (cond ((geq j i)
  845. (progn
  846. (setq wc (exprtype!> (getel2!> w i j)))
  847. (cond ((and (not(eqn i j)) wc) % off diag
  848. (setq wod t)))
  849. (cond ((eqn wc 2) % non const
  850. (setq wnc t)))
  851. )))))
  852. (cond ((not wnc) (set wd 1))
  853. (t (set wd 2)))
  854. (cond ((not wod) (set wt 2))
  855. (t (set wt 3)))
  856. (return t)))
  857. (t (set wt nil))))
  858. % Determines expression type:
  859. % NIL - zero, 1 - constant, 2 - general
  860. (de exprtype!> (w)
  861. (cond ((null w) nil)
  862. (t (exprtype1!> w))))
  863. (de exprtype1!> (w)
  864. (cond
  865. ((atom w)
  866. (cond
  867. ((numberp w) 1)
  868. ((get w '!=cord) 2)
  869. ((get w '!=depend) (exprtype1!> (cons nil (cdr(get w '!=depend)))))
  870. (t 1)))
  871. (t(proc nil
  872. (setq w (cdr w))
  873. (while!> w
  874. (cond ((eqn 2 (exprtype1!> (car w))) (return 2)))
  875. (setq w (cdr w)))
  876. (return 1)))))
  877. % [FTYPE] NIL - unknown, 1 - holonomic, 2 - diag, 3 - general
  878. % Frame holomonic ?
  879. (de fholop!> nil
  880. (cond ((and ![ftype!] (eqn ![ftype!] 1)) t)
  881. (t nil)))
  882. % Inverse Frame holomonic ?
  883. (de ifholop!> nil
  884. (cond ((and ![fitype!] (eqn ![fitype!] 1)) t)
  885. (t nil)))
  886. % This crucial predicate defines Holonomic Regime.
  887. % In this case frame indixes are not differnt from
  888. % holonomic ones. This is important in coordinates
  889. % transformations and in the Dc/Lie covar. operations.
  890. (de holonomicp!> nil
  891. (and !*holonomic % holonomic is on
  892. (not ![umod!]) % not if basis mode
  893. (or (null !#!T) (fholop!>)) % t is holonomic or absent
  894. (or (null !#!D) (ifholop!>)))) % d is holonomic or absent
  895. % Frame diagonal ?
  896. (de fdiagp!> nil
  897. (cond ((and ![ftype!] (eqn ![ftype!] 2)) t)
  898. (t nil)))
  899. % Inverse Frame diagonal ?
  900. (de ifdiagp!> nil
  901. (cond ((and ![fitype!] (eqn ![fitype!] 2)) t)
  902. (t nil)))
  903. % [MTYPE] NIL - unknown, 1 - null, 2 - diag, 3 - general
  904. % [DTYPE] NIL - unknown, 1 - constant, 2 - general
  905. % Metric diagonal or null?
  906. (de motop!> nil
  907. (cond ((and ![mtype!] (leq ![mtype!] 2)) t)
  908. (t nil)))
  909. % Inverse Metric diagonal or null?
  910. (de imotop!> nil
  911. (cond ((and ![mitype!] (leq ![mitype!] 2)) t)
  912. (t nil)))
  913. % Null Metric ?
  914. (de mnullp!> nil
  915. (cond ((and ![mtype!] (eqn ![mtype!] 1)) t)
  916. (t nil)))
  917. (de imnullp!> nil
  918. (cond ((and ![mitype!] (eqn ![mtype!] 1)) t)
  919. (t nil)))
  920. % Maps `diagonal' index to its adjacent ...
  921. (de ai!> (wa)
  922. (cond ((eqn ![mtype!] 1)
  923. (cond ((eqn wa 1) 0)
  924. ((eqn wa 0) 1)
  925. ((eqn wa 2) 3)
  926. ((eqn wa 3) 2)))
  927. (t wa)))
  928. % `Diagonal' element of Metric/Inverse Metric ...
  929. (de diagm!> (w) (getmetr!> w (ai!> w)))
  930. (de diagmi!> (w) (getimetr!> w (ai!> w)))
  931. % Predicat of +--- version in the spinorial regime ...
  932. (de pmmm!> nil (eqn (car ![sgn!]) 1))
  933. (de mppp!> nil (eqn (car ![sgn!]) -1))
  934. %------ Restrictors for Constrained Data Types and Ways ------------------
  935. % Only dim=4 ...
  936. (de ttt4!> nil
  937. (cond ((not(eqn ![dim!] 4)) 7805)
  938. (t nil)))
  939. % We need affine parameter ...
  940. (de tttapar!> nil
  941. (cond ((null ![apar!]) 7302)
  942. (t nil)))
  943. % Need Torsion ...
  944. (de tttq!> nil
  945. (cond ((null !*torsion) 6500)
  946. (t nil)))
  947. % Need Nonmetricity ...
  948. (de tttn!> nil
  949. (cond ((null !*nonmetr) 6501)
  950. (t nil)))
  951. % Need Torsion or Nonmetricity ...
  952. (de tttqorn!> nil
  953. (cond ((not(or !*torsion !*nonmetr)) 6503)
  954. (t nil)))
  955. % Need Torsion and Nonmetricity ...
  956. (de tttqandn!> nil
  957. (cond ((not(and !*torsion !*nonmetr)) 6502)
  958. (t nil)))
  959. % Need Torsion but not Nonmetr ...
  960. (de tttqnotn!> nil
  961. (cond ((not !*torsion) 6500)
  962. (!*nonmetr 6504)
  963. (t nil)))
  964. % Need Off Nonmetr ...
  965. (de tttnotn!> nil
  966. (cond (!*nonmetr 6504)
  967. (t nil)))
  968. % Need Nonmetr but not Torsion ...
  969. (de tttnnotq!> nil
  970. (cond ((not !*nonmetr) 6501)
  971. (!*torsion 6505)
  972. (t nil)))
  973. % No Torsion and No Nonmetricity ...
  974. (de tttnotqn!> nil
  975. (cond ((or !*nonmetr !*torsion) 6506)
  976. (t nil)))
  977. % We need default diagonal metric ...
  978. (de tttdiag!> nil
  979. (cond ((or (null !#!G) (null ![mtype!]) (null ![dtype!])) 7806)
  980. ((not(eqn ![mtype!] 2)) 7806)
  981. ((not(eqn ![dtype!] 1)) 7806)
  982. (t nil)))
  983. % Spinorial restrictor ...
  984. (de sp!> nil
  985. (cond ((not(eqn ![dim!] 4)) 78040)
  986. ((null !#!G) 7804)
  987. ((null ![mtype!]) 7804)
  988. ((not(eqn ![mtype!] 1)) 7804)
  989. ((and !#!G!I (not(eqn ![mitype!] 1))) 7804)
  990. (t nil)))
  991. % Spinorial but NONMETR must be Off ...
  992. (de sp!-n!> nil
  993. (cond (!*nonmetr 6504)
  994. ((not(eqn ![dim!] 4)) 78040)
  995. ((null !#!G) 7804)
  996. ((null ![mtype!]) 7804)
  997. ((not(eqn ![mtype!] 1)) 7804)
  998. ((and !#!G!I (not(eqn ![mitype!] 1))) 7804)
  999. (t nil)))
  1000. % dim>n restrictors ...
  1001. (de deq2!> nil (cond ((not(eqn ![dim!] 2)) 650022) (t nil)))
  1002. (de dg2!> nil (cond ((not(greaterp ![dim!] 2)) 65002) (t nil)))
  1003. (de dg3!> nil (cond ((not(greaterp ![dim!] 3)) 65003) (t nil)))
  1004. (de dg4!> nil (cond ((not(greaterp ![dim!] 4)) 65004) (t nil)))
  1005. (de dg5!> nil (cond ((not(greaterp ![dim!] 5)) 65005) (t nil)))
  1006. % Check consrtains for one object WI ...
  1007. (de constrp!> (wi)
  1008. (cond ((null (setq wi (get wi '!=constr))) nil)
  1009. (t (constrp1!> wi))))
  1010. (de constrp1!> (w) % w - list of constraints ...
  1011. (cond ((null w) nil)
  1012. ((eval(car w)) (eval(car w)))
  1013. (t (constrp1!>(cdr w)))))
  1014. % Check constrains for list of objects ...
  1015. (de constrpl!> (lst)
  1016. (cond ((null lst) nil)
  1017. (t(prog (w)
  1018. (setq w (constrp!>(car lst)))
  1019. (cond (w (progn (setq ![er!] w)
  1020. (doubo!>(car lst))
  1021. (return !!er!!)))
  1022. (t (return (constrpl!> (cdr lst)))))))))
  1023. %------ Main Data Calculation Algorithm ----------------------------------
  1024. % Main Data Calculation Recursive Algorithm. Returns:
  1025. % !!ER!! - Some error in the process of calculation.
  1026. % NIL - Cannot calculate. Too few data or no any ways.
  1027. % T - Done.
  1028. (de request!> (nam)
  1029. (cond
  1030. ((eval nam) t) % already exists ...
  1031. ((memq nam ![chain!]) nil) % already in the chain ...
  1032. ((constrp!> nam) % constrained object ...
  1033. (progn (doubo!> nam) (erm!>(constrp!> nam)) nil))
  1034. (t(proc (w wa wy w1w)
  1035. % trying to find method for calculation ...
  1036. (cond((not ![way!]) (progn % choosing way ...
  1037. (setq w (get nam '!=way))
  1038. (cond ((null w) (return nil))) % no any way ...
  1039. (setq wa (mainway!> w))
  1040. (cond ((null wa) (setq wa (firstgoodway!> w))))
  1041. (cond ((null wa) (return nil))) % no any appropriate way ...
  1042. (setq w1w (car wa))
  1043. (setq wy (caddr wa))
  1044. (setq w (cdddr wa)) ))
  1045. (t(progn % alternative way ...
  1046. (setq w (get nam '!=way))
  1047. (cond((null w) % no any ways for this object ...
  1048. (progn (setq ![er!] 6043) (doubl!> ![way!])
  1049. (setq ![way!] nil) (return !!er!!))))
  1050. (setq w (getthisway!> ![way!] w))
  1051. (cond
  1052. ((eq w !!er!!) (return !!er!!))
  1053. ((null w) % unknown way ...
  1054. (progn (setq ![er!] 6043) (doubl!> ![way!])
  1055. (setq ![way!] nil) (return !!er!!))))
  1056. (cond((setq wa (constrp1!>(ncons(cadr w)))) % constr.way ...
  1057. (progn (cantway!> nam ![way!]) (setq ![way!] nil)
  1058. (setq ![er!] wa) (return !!er!!))))
  1059. (setq ![way!] nil)
  1060. (setq w1w (car w))
  1061. (setq wy (caddr w))
  1062. (setq w (cdddr w)))))
  1063. % now: w - reqired data list, w1w - way name,
  1064. % wy - calculating call for ways
  1065. (setq ![chain!] (cons nam ![chain!]))
  1066. (while!> w % request for data required for calculation ...
  1067. (cond((and (pairp(car w)) (eval(caar w)))
  1068. (setq w (appmem!>(cdar w)(cdr w))) ) % new group ...
  1069. ((and (pairp(car w)) (null(eval(caar w))))
  1070. (setq w (cdr w)) )) % skip group ...
  1071. (tohead (or(null w)(pairp(car w))))
  1072. (setq wa (request!>(car w)))
  1073. (cond
  1074. ((eq wa !!er!!) (return !!er!!))
  1075. ((not wa) (progn (trsf!>(car w)) (return nil))))
  1076. (setq w (cdr w)))
  1077. (setq w (eval wy)) % calculation ...
  1078. (cond((eq w !!er!!)(return !!er!!)))
  1079. (trsc!> nam w1w) % successful calculation ...
  1080. (return t)))))
  1081. % Seek main way if awailable ...
  1082. (de mainway!> (wl)
  1083. (cond ((null wl) nil)
  1084. ((and (not(eval(cadar wl))) (mainwayp!>(cdddar wl)))
  1085. (car wl))
  1086. (t (mainway!> (cdr wl)))))
  1087. (de mainwayp!> (w)
  1088. (proc (wt wc)
  1089. (while!> w
  1090. (setq wc (car w))
  1091. (cond
  1092. ((and (pairp wc) (eq (car wc) t))
  1093. (cond ((eval(cadr wc)) (setq wt t))
  1094. (t (return nil)))))
  1095. (setq w (cdr w)))
  1096. (return wt)))
  1097. % Seek first appropriate way ...
  1098. (de firstgoodway!> (wl)
  1099. (cond ((null wl) nil)
  1100. ((not(eval(cadar wl))) (car wl))
  1101. (t (firstgoodway!> (cdr wl)))))
  1102. % Get This Way from List ...
  1103. (de getthisway!> (wy wl)
  1104. (prog (w)
  1105. (cond ((or (eqs!> wy '(by standard way)) % word!!!
  1106. (eqs!> wy '(using standard way))) % word!!!
  1107. (setq wy nil)))
  1108. (setq w (getthisway1!> wy wl)) % searching by name of the way ...
  1109. (cond (w (return w))
  1110. ((memqs!> (car wy) '(from using)) (setq wy (cdr wy))) % word!!!
  1111. (t (return nil)))
  1112. (cond ((null wy) (return nil)))
  1113. (setq wy (dgood!> wy))
  1114. (cond ((null wy) (return nil))
  1115. ((and (eq wy !!er!!) (eqn ![er!] 6030))
  1116. (prog2 (setq ![er!] nil) (return nil)))
  1117. ((eq wy !!er!!) (return !!er!!))
  1118. ((cdr wy) (return nil)))
  1119. (return (getthisway2!> (car wy) wl)) % searching by data name ...
  1120. ))
  1121. (de getthisway1!> (wy wl)
  1122. (cond ((null wl) wl)
  1123. ((eqs!> wy (caar wl)) (car wl))
  1124. (t (getthisway1!> wy (cdr wl)))))
  1125. (de getthisway2!> (wy wl)
  1126. (cond ((null wl) wl)
  1127. ((memq!> wy (cdddar wl)) (car wl))
  1128. (t (getthisway2!> wy (cdr wl)))))
  1129. (de memq!> (w lst)
  1130. (cond ((null lst) nil)
  1131. ((or (eq w (car lst))
  1132. (and (pairp(car lst)) (memq w (car lst)))) t)
  1133. (t (memq!> w (cdr lst)))))
  1134. % Tries to calculate all data in the list LST if AUTO is On.
  1135. % ERR interrupt is can not do it.
  1136. (de require!> (lst)
  1137. (cond((null lst) nil)
  1138. (t (prog (wa)
  1139. (cond(!*auto
  1140. (foreach!> x in lst do (progn
  1141. (setq ![chain!] nil)
  1142. (setq wa (request!> x))
  1143. (cond((eq wa !!er!!)
  1144. (prog2 (trsf!> x) (err!> ![er!])))
  1145. ((null wa) (cantfd!> x)))))))
  1146. (foreach!> x in lst do
  1147. (cond((null(eval x)) (cantfd!> x)))))) ))
  1148. % Tries to calculate X if AUTO is On.
  1149. % ERR interrupt is can not do it.
  1150. (de require1!> (x)
  1151. (prog (wa)
  1152. (cond(!*auto (progn
  1153. (setq ![chain!] nil)
  1154. (setq wa (request!> x))
  1155. (cond((eq wa !!er!!)
  1156. (prog2 (trsf!> x) (err!> ![er!])))
  1157. ((or(null wa)(null(eval x))) (cantfd!> x)) ))))))
  1158. (de cantfd!> (w) (prog2 (trsf!> w) (err!> 6046)))
  1159. %------- Commands translation -------------------------------------
  1160. % General Command translation with Compound Mechanism ...
  1161. % Command -> List Of Commands -> List of Evaluations
  1162. (de instrs!> (lst)
  1163. (prog nil
  1164. (setq lst (composin!> lst)) % compound command maybe ...
  1165. (cond (!*showcommands (showcommands!> lst))) % print the result
  1166. (cond ((eq lst !!er!!) (prog2 (erm!> 6044) (return lst))))
  1167. (setq lst (mapcar lst (function instr!>)))
  1168. (cond ((memq !!er!! lst) (return !!er!!)))
  1169. (return lst)))
  1170. % One Command translation ...
  1171. % Command text -> Evaluation
  1172. (de instr!> (lst)
  1173. (proc (w wa)
  1174. (cond ((null lst) (return '(nil next!>))))
  1175. (setq wa lst)
  1176. (setq w ![instr!])
  1177. (while!> lst
  1178. (setq w (assocf!> (car lst) w))
  1179. (cond
  1180. ((null w) (setq lst nil))
  1181. ((eq(car w)(quote !!))
  1182. (cond((cdr lst)(setq lst nil))
  1183. (t(return(cons t(cdr w))))))
  1184. ((eq(car w)(quote !!!!))
  1185. (return(cons nil(cons(cadr w)(cons(cdr lst)(cddr w))))))
  1186. (t(setq lst(cdr lst))))
  1187. (exitif(null lst)))
  1188. (cond((and(null(cdr wa))(stringp(car wa))) % in ...
  1189. (return(list nil 'from!> wa)))
  1190. ((memqs!> 'for wa) % word!!! % print ...
  1191. (return(list nil 'printi!> wa)))
  1192. ((memq '!= wa) % assign ...
  1193. (return(list nil 'seti!> wa)))
  1194. (t(return(list nil 'printi!> wa))) % print ... ?
  1195. )
  1196. (closewrite!>)
  1197. (gprinreset!>)
  1198. (gprin!> "Unknown command - '")
  1199. (gprinwb!> wa)(gprin!> "'.")(gterpri!>)
  1200. (return !!er!! )))
  1201. % Print list of commands ...
  1202. (de showcommands!> (lst)
  1203. (cond ((null lst) (gprinreset!>))
  1204. ((eq lst !!er!!) !!er!!)
  1205. (t(progn
  1206. (gprinreset!>)(setq ![gptab!] 4)
  1207. (gprin!> " ")
  1208. (gprinwb!> (car lst))
  1209. (gprin!> ";")
  1210. (gterpri!>)
  1211. (showcommands!> (cdr lst))))))
  1212. % Conpound command -> commands list ...
  1213. (de composin!> (lst)
  1214. (cond
  1215. % Comments in command ...
  1216. ((and (not(eq (car lst) '!%)) (memq '!% lst)) (proc (w)
  1217. (while!> (not (eq (car lst) '!%))
  1218. (setq w (cons (car lst) w))
  1219. (setq lst (cdr lst)))
  1220. (return (cons lst (composin!> (reverse w))))))
  1221. % Re prefix ...
  1222. ((or (eq (car lst) '!R!E) (eq (car lst) '!R!e) (eq (car lst) '!r!e))
  1223. (cond ((and (cdr lst) (eq (cadr lst) '!-))
  1224. (composin!> (append '(erase and) (cddr lst))))
  1225. (t (ncons lst))))
  1226. % Not Composite Command ...
  1227. ((or (not (memqs!> (car lst) ![icompos!])) % compound version forbidden
  1228. (not (or (memq '!& lst)(memq '!, lst)(memqs!> 'and lst)))) % word!!!
  1229. (ncons lst))
  1230. % Composite Command Itself ...
  1231. (t(proc (w wa wb wc wd)
  1232. (setq lst (memll!> lst '(!& !, and))) % word!!!
  1233. (cond ((eq lst !!er!!) (prog2(setq ![er!] 6044)(return !!er!!))))
  1234. % Select Left Commands ...
  1235. (while!> lst
  1236. (setq w (inspar!> (car lst)))
  1237. (cond ((eq w !!er!!) (return !!er!!)))
  1238. (setq wa (cons (car w) wa))
  1239. (setq lst (cdr lst))
  1240. (exitif (cdr w)))
  1241. (cond ((cdr w) (setq lst (cons (cdr w) lst))))
  1242. % Select Paremeters ...
  1243. (while!> (and lst (not(insp!>(car lst))))
  1244. (setq w (parway!> (car lst)))
  1245. (cond ((null(car w)) (return !!er!!)))
  1246. (setq wb (cons (car w) wb))
  1247. (setq lst (cdr lst))
  1248. (exitif (cdr w)))
  1249. (setq wc (cdr w))
  1250. % Right Commands ...
  1251. (while!> lst
  1252. (cond ((not(insp!>(car lst))) (return !!er!!)))
  1253. (setq wd (cons (car lst) wd))
  1254. (setq lst (cdr lst)))
  1255. (cond (wd % it after right comm
  1256. (setq wd (cons (wiplit!>(car wd)) (cdr wd)))))
  1257. (setq wa (reverse wa))
  1258. (setq wb (reverse wb))
  1259. (setq wd (reverse wd))
  1260. % WA - Left Commands
  1261. % WB - Parameters
  1262. % WC - Way
  1263. % WD - Right commands
  1264. (setq w nil)
  1265. (cond ((null wb) (return wa)))
  1266. (while!> wa
  1267. (cond ((and (wucp!>(car wa)) wc)
  1268. (setq w (cons (append (car wa) wc) w))))
  1269. (setq w (append w
  1270. (foreach!> x in wb collect
  1271. (append (car wa) (append x
  1272. (cond ((wucp!>(car wa)) nil)
  1273. (t wc)))))))
  1274. (cond
  1275. ((and (ucp!>(car wa)) wc)
  1276. (setq w (append w '((ends))))) % word!!!
  1277. ((and (wcp!>(car wa)) wc)
  1278. (setq w (append w '((endw)))))) % word!!!
  1279. (setq wa (cdr wa)))
  1280. (while!> wd
  1281. (setq w (append w
  1282. (foreach!> x in wb collect (append (car wd) x))))
  1283. (setq wd (cdr wd)))
  1284. (return w)
  1285. ))))
  1286. % Command predicate ...
  1287. (de insp!> (lst)
  1288. (memqs!> (car lst) ![icompos!]))
  1289. % Write, Unload commands predicate ...
  1290. (de wucp!> (w)
  1291. (memqs!> (car w) '(write save unload))) % word!!!
  1292. (de wcp!> (w)
  1293. (memqs!> (car w) '(write))) % word!!!
  1294. (de ucp!> (w)
  1295. (memqs!> (car w) '(save unload))) % word!!!
  1296. % Way predicate ...
  1297. (de bftp!> (w)
  1298. (memqs!> w '( by from using to with in !> ))) % word!!!
  1299. % LST -> ( Command . Parameters ) ...
  1300. (de inspar!> (lst)
  1301. (proc (w wa)
  1302. (cond ((not(memqs!> (car lst) ![icompos!])) (return !!er!!)))
  1303. (setq w ![instr!])
  1304. (while!> lst
  1305. (setq w (assocf!> (car lst) w))
  1306. (cond ((null w) (return !!er!!)))
  1307. (exitif (or (eq (car w) '!!) (eq (car w) '!!!!)))
  1308. (setq wa (cons (car lst) wa))
  1309. (setq lst (cdr lst)))
  1310. (cond ((null lst) (return !!er!!)))
  1311. (return(cons(reverse(cons(car lst) wa))(cdr lst)))))
  1312. % LST -> ( Parameters . Way ) ...
  1313. (de parway!> (lst)
  1314. (proc (wa)
  1315. (while!> (and lst (not(bftp!>(car lst)))) % by from ...
  1316. (setq wa(cons(car lst) wa))
  1317. (setq lst(cdr lst)))
  1318. (return(cons(reverse wa)lst))))
  1319. % Split LST by WI=( and , & ) delimiters ...
  1320. (de memll!> (lst wi)
  1321. (proc(wa wb)
  1322. (setq lst(cons(car wi) lst))
  1323. (while!> lst
  1324. (setq lst(cdr lst))
  1325. (while!>(and lst(not(memqs!>(car lst)wi)))
  1326. (setq wa(cons(car lst)wa))
  1327. (setq lst(cdr lst)))
  1328. (cond
  1329. ((null wa)(return !!er!!))
  1330. (t(prog2 (setq wb(cons(reversip wa)wb))
  1331. (setq wa nil)))))
  1332. (return(reversip wb))))
  1333. % Cut It etc in the end of LST ...
  1334. (de wiplit!> (lst)
  1335. (cond ((null(cdr lst))
  1336. (cond ((memqs!> (car lst) '(it them)) nil) % word!!!
  1337. (t lst)))
  1338. (t (cons (car lst) (wiplit!> (cdr lst))))))
  1339. %-------- Commands execution --------------------------------------------
  1340. % Execute command from the terminal ...
  1341. (de rund!> nil
  1342. (proc nil
  1343. (setq ![firsti!] t)
  1344. (loop!>
  1345. (cond ((eq (runcom!> nil) !!stop!!) (return !!stop!!)))
  1346. (setq ![firsti!] nil))
  1347. ))
  1348. % This is main command executer. Work with the ERRORSET
  1349. % and catches possible internal REDUCE errors. The RUNCOM>
  1350. % is called only in tree places:
  1351. % (1) in main function RUND> as the basic commands' loop (RUNCOM> NIL)
  1352. % (2) in the In command for each command COM from file (RUNCOM> COM)
  1353. % (3) in the Pause commad as another command loop (RUNCOM> NIL)
  1354. % If WA=NIL then the command is requested from the terminal
  1355. % otherwise the WA is executed.
  1356. (de runcom!> (wa)
  1357. (proc (wp wq wr w wc wx)
  1358. (cond (wa % command from file must be printed
  1359. (progn (setq wx t)
  1360. (setq w wa) % print commands
  1361. (gprinreset!>) (setq ![gptab!] 3)
  1362. (gprin!> '!<!-! )
  1363. (gprinwb!> w)
  1364. (gprin!> ";")
  1365. (gterpri!>)
  1366. (gprinreset!>) )))
  1367. (loop!>
  1368. (cond (wa (setq wa (instrs!> wa)))) % command translation
  1369. labela
  1370. (cond
  1371. ((or (null wa) (eq wa !!er!!)) % take command from terminal if
  1372. (progn
  1373. (cond ((eq wa !!er!!) (closewrite!>)))
  1374. (setq wp t)
  1375. (setq wq t)
  1376. (cond (wx (prin2 "Please enter correct command:")
  1377. (terpri)))
  1378. (cond ( (eq (loop!> % getting a correct command
  1379. (cond ((iscsl!>) (printprompt promptstring!*)))
  1380. (setq wa (listok!> '( !; )))
  1381. (cond ((and (not (eq wa !!er!!))
  1382. (not (eq (bc!> wa) !!er!!)))
  1383. (progn
  1384. (setq wp nil) % success
  1385. (setq wa (car(mklevel!> wa)))))
  1386. (t (progn
  1387. (erm!> ![er!])
  1388. (setq ![er!] nil))))
  1389. (tohead wp) % failure => loop again
  1390. (return nil)
  1391. ) !!er!!)
  1392. (return !!er!!)))))
  1393. (t (setq wq nil)))
  1394. (tohead wq) % we have not a command so loop again
  1395. % here we have translated list of commands and we
  1396. % are going to execute them
  1397. (while!> wa % commands list evaluation (execution)
  1398. (setq ![lsrs!] nil) % these are the values that not bad to
  1399. (setq ![ivs!] nil) % clear before each commands execution
  1400. (cond % coordinates must be specified!
  1401. ((and (null ![cord!]) (not (flagp (cadar wa) '!+unloc)))
  1402. (erm!> 7301) (setq wa !!er!!) (go labela)))
  1403. % (tohead % coordinates must be specified!
  1404. % (and (null ![cord!])
  1405. % (not (flagp (cadar wa) '!+unloc))
  1406. % (progn (erm!> 7301) (setq wa (cdr wa)) t) ))
  1407. % execution ...
  1408. (setq wc (cadar wa))
  1409. (setq wr
  1410. (list 'apply
  1411. (list2 'function (cadar wa))
  1412. (list2 'quote
  1413. (cond
  1414. ((caar wa) (mapcar (cddar wa) 'eval))
  1415. (t (cons (caddar wa)
  1416. (mapcar (cdddar wa) 'eval)))))))
  1417. (setq wr (errorset!> wr ![erst1!] ![erst2!]))
  1418. (cond ((atom wr) (algterpri!>)
  1419. (setq ![er!] wr)
  1420. (setq wr !!er!!))
  1421. (t (setq wr (car wr))))
  1422. (cond ((eq wr !!stop!!) (return !!stop!!))
  1423. ((eq wr !!er!!)
  1424. (progn (erm!> ![er!])
  1425. (setq wa nil)
  1426. (setq ![er!] nil))))
  1427. (exitif (null wa)) % error, so exit it
  1428. (setq wa (cdr wa)))
  1429. (tohead (eq wr !!er!!)) % making the cycle in the case of the error.
  1430. %(cond ((not(eq wc 'comment!>)) (setq ![firsti!] nil)))
  1431. (cond ((and (not(eq wc 'comment!>)) (not(eq wc 'grgout!>)))
  1432. (setq ![firsti!] nil)))
  1433. (return wr))))
  1434. % Brackets count ...
  1435. (de bc!> (lst)
  1436. (proc (wc) (setq wc 0)
  1437. (while!> lst
  1438. (cond((eq(car lst) '!()(setq wc(add1 wc)))
  1439. ((eq(car lst) '!))(setq wc(sub1 wc))))
  1440. (cond((lessp wc 0)(prog2(setq ![er!] 6100)(return !!er!!))))
  1441. (setq lst(cdr lst)))
  1442. (cond((not(eqn wc 0))
  1443. (prog2(setq ![er!] 6100)(return !!er!!)))) ))
  1444. %========== End of GRGmain.sl ==========================================%