File: basic.mac

package info (click to toggle)
maxima 5.21.1-2squeeze
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 94,928 kB
  • ctags: 43,849
  • sloc: lisp: 298,974; fortran: 14,666; perl: 14,325; tcl: 10,494; sh: 4,052; makefile: 2,975; ansic: 471; awk: 24; sed: 7
file content (33 lines) | stat: -rw-r--r-- 1,039 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*-*-MACSYMA-*-*/

eval_when([translate,batch,demo],
          if get('sharem,'version) = false
             then load(autolo))$

herald_package(basic)$


/* These are basic macros, nothing in here should call anything
   complicated. PUSH and POP here are the simple version
   which do not hack once-only evaluation. 
   I might say that these macros are around mostly so
   that the code for implementing the more complicated
   macros, including the once-only stuff, can be simpler.
*/

prog1(statement1,[statements])::=
 buildq([statement1,statements,local:?gentemp()],
        lambda([local],splice(statements),local)(statement1))$

symbolcheck(x):=
 if symbolp(x) then x else error("arg must be a symbol",x)$

push(c,l)::=(symbolcheck(l),buildq([c,l],l:cons(c,l)))$

pop(l)::=(symbolcheck(l),buildq([l],prog1(first(l),l:rest(l))))$

/* TR_EV is a pretty sorry way to get optimization
   by Translation-time evaluation. User directed constant-folding
   you might call it. TR_EV has other uses. */

tr_ev(x)::=buildq([x],?meval(x))$