3
3
/* A macro for defining simple substitution macros.
4
4
George Carrette, 12:20am Tuesday, 12 August 1980 */
6
EVAL_WHEN(TRANSLATE,MODEDECLARE(FUNCTION(GETCHARN),FIXNUM))$
8
GENSYM_CONVENTIONP(SYMBOL):=
9
IF GETCHARN(SYMBOL,1)=GETCHARN('%,1) AND
10
GETCHARN(SYMBOL,2)=GETCHARN('%,1) THEN TRUE ELSE FALSE$
12
GENSYM_CONVENTIONS(EXP):=
13
IF ATOM(EXP) THEN EXP ELSE FALSE
14
BLOCK([GENS:[],TEMP:GENSYM_CONVENTIONS(PART(EXP,0))],
15
IF NOT TEMP=FALSE THEN GENS:CONS(TEMP,GENS),
17
WHILE NOT EXP=[] DO (TEMP:GENSYM_CONVENTIONS(FIRST(EXP)),
18
IF NOT TEMP=FALSE THEN GENS:CONS(TEMP,GENS),
20
IF GENS=[] THEN FALSE ELSE GENS)$
25
(IF ATOM(HEADER) THEN ERROR("bad arg to \"=>\"")
26
MAPLIST(LAMBDA([U],IF NOT ATOM(U)
27
THEN ERROR(U,"Bad variable in arglist of \"=>\"")),
29
BLOCK([GENS:GENSYM_CONVENTIONS(BODY)],
6
eval_when(translate,modedeclare(function(getcharn),fixnum))$
8
gensym_conventionp(symbol):=
9
if getcharn(symbol,1)=getcharn('%,1) and
10
getcharn(symbol,2)=getcharn('%,1) then true else false$
12
gensym_conventions(exp):=
13
if atom(exp) then exp else false
14
block([gens:[],temp:gensym_conventions(part(exp,0))],
15
if not temp=false then gens:cons(temp,gens),
17
while not exp=[] do (temp:gensym_conventions(first(exp)),
18
if not temp=false then gens:cons(temp,gens),
20
if gens=[] then false else gens)$
25
(if atom(header) then error("bad arg to \"=>\"")
26
maplist(lambda([u],if not atom(u)
27
then error(u,"bad variable in arglist of \"=>\"")),
29
block([gens:gensym_conventions(body)],