1 ;;; -*- Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*- ;;;;
2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 ;;; The data in this file contains enhancments. ;;;;;
5 ;;; Copyright (c) 1984,1987 by William Schelter,University of Texas ;;;;;
6 ;;; All rights reserved ;;;;;
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 ;;; (c) Copyright 1980 Massachusetts Institute of Technology ;;;
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13 (macsyma-module rzmac macro
)
15 ;;; *****************************************************************
16 ;;; ***** MACROS ******* ASSORTED MACROS FOR GENERAL REPRESENTATION *
17 ;;; *****************************************************************
19 (defmacro *bind
* (bindings &body body
)
20 (nconc (list 'do
(mapcar #'(lambda (q)
24 (list (car q
) (caddr q
)))
28 (maplist #'(lambda (x)
34 ;; Returns the negation of VALUE if PREDICATE is true. Otherwise, just
37 (defmacro negate-if
(predicate value
&aux
(temp (gensym)))
38 `(let ((,temp
,predicate
))
43 ;; Setq's the first variable to VALUE if SWITCH is true, and sets the second
44 ;; variable otherwise.
46 (defmacro set-either
(first-var second-var switch value
&aux
(temp (gensym)))
47 `(let ((,temp
,value
))
49 (setq ,first-var
,temp
)
50 (setq ,second-var
,temp
))))
52 ;; symbolic arithmetic macros
54 (defmacro m
+ (&rest body
) `(add* .
,body
))
56 (defmacro m
* (&rest body
) `(mul* .
,body
))
58 (defmacro m1
+ (x) `(add* 1 ,x
))
60 (defmacro m1-
(x) `(add* -
1 ,x
))
62 (defmacro m
// (a1 &optional
(a2 nil
2args
))
67 (defmacro m-
(a1 &optional
(a2 nil
2args
))
72 (defmacro m^
(b e
) `(power* ,b
,e
))
74 (defmacro m
+l
(l) `(addn ,l nil
))
76 (defmacro m
*l
(l) `(muln ,l nil
))
78 (defmacro m
+t
(&rest body
) `(add .
,body
))
80 (defmacro m
*t
(&rest body
) `(mul .
,body
))
82 (defmacro m1
+t
(x) `(add 1 ,x
))
84 (defmacro m1-t
(x) `(add -
1 ,x
))
86 (defmacro m
//t
(a1 &optional
(a2 nil
2args
))
91 (defmacro m-t
(a1 &optional
(a2 nil
2args
))
96 (defmacro m^t
(b e
) `(power ,b
,e
))
98 (defmacro m
+lt
(l) `(addn ,l
,t
))
100 (defmacro m
*lt
(l) `(muln ,l
,t
))