mirror of
https://github.com/PDP-10/its.git
synced 2026-01-30 13:36:42 +00:00
469 lines
19 KiB
Common Lisp
Executable File
469 lines
19 KiB
Common Lisp
Executable File
;;; -*- Mode:LISP; Package:MACSYMA -*-
|
|
|
|
; ** (c) Copyright 1976, 1983 Massachusetts Institute of Technology **
|
|
;; Enhancements (c) 1983, Symbolics, Inc. All Rights Reserved.
|
|
;; The data and information in the Enhancements is proprietary
|
|
;; to, and a valuable trade secret of, SYMBOLICS, INC., a
|
|
;; Delaware corporation. It is given in confidence by
|
|
;; SYMBOLICS, and may not be used as the basis of manufacture,
|
|
;; or be reproduced or copied, or distributed to any other
|
|
;; party, in whole or in part, without the prior written
|
|
;; consent of SYMBOLICS.
|
|
|
|
(SETQ $LOADPRINT NIL)
|
|
;This shouldn't be needed any more --kmp
|
|
;(COND ((STATUS FEATURE MACLISP) (LOAD '((LISP)DEFMAX))))
|
|
|
|
(DEFSCRIPT $INTRO
|
|
"Welcome to the MACSYMA Primer. This is the script called INTRO."
|
|
"Please terminate responses to all questions with a semi-colon (;).
|
|
You may delete any characters you have typed by using
|
|
the delete or rub-out key on your console (control-H or backspace
|
|
for VAX systems). The deleted
|
|
character will be erased if you are using a display terminal.
|
|
If you are using a printing terminal, it will be
|
|
typed back so you know what has been deleted."
|
|
"If you do not understand how to type an expression, or have tried
|
|
several times and wish to give up, you may type NO; and the
|
|
PRIMER will show you the correct way to do it."
|
|
"In this PRIMER session, after an optional introduction to
|
|
MACSYMA syntax, a few of the specialized MACSYMA commands
|
|
will be introduced. After that we will discuss some of the
|
|
facilities of MACSYMA which allow you to manipulate algebraic
|
|
expressions within the computer in much the same way you
|
|
do on paper."
|
|
"MACSYMA is a system for symbolic algebraic manipulation.
|
|
It uses a syntax resembling ALGOL 60."
|
|
"Do you need help with MACSYMA syntax?"
|
|
(AND (YESORNO) (SCRIPT '$SYNTAX NIL))
|
|
"MACSYMA contains a large set of commands for manipulating
|
|
algebraic expressions. Among these are commands to
|
|
factor, expand, differentiate, integrate, substitute and
|
|
simplify. Lets try an example:"
|
|
"Type in"
|
|
(DISPLA EXAMPLE1)
|
|
(INCHKP 'CHKEXONEP)
|
|
"Now you may want this expression multiplied out. The EXPAND command
|
|
will do this for you. It takes one argument, the expression
|
|
to be EXPANDed. You may refer to an expression you have typed
|
|
in already by using its D-line label. Type:"
|
|
(PCLINE (LIST '($EXPAND) DLABEL))
|
|
(CMDCHKP (LIST '($EXPAND) DLABEL))
|
|
"On the other hand, factored form is smaller, and the FACTOR command
|
|
in MACSYMA will factor expressions for you. There is a short
|
|
hand for the D-line label of the last expression
|
|
you typed, the character %. Type"
|
|
(PCLINE '(($FACTOR) $%))
|
|
(CMDCHKP (LIST '($FACTOR) DLABEL))
|
|
"The MACSYMA commands to integrate and differentiate (INTEGRATE and
|
|
DIFF) both take a second argument -- the variable to integrate
|
|
or differentiate with respect to. The second argument is
|
|
separated from the first by a comma. For example,"
|
|
(PCLINE (LIST '($INTEGRATE) DLABEL '$X))
|
|
"If you would type in the expression for"
|
|
(DISPLA EXAMPLE2)
|
|
"Then we can try integrating and differentiating it."
|
|
(INCHK EXAMPLE2)
|
|
"Now use the INTEGRATE command to integrate the last expression"
|
|
(setq $LOADPRINT T)
|
|
(INCHK (LIST '($INTEGRATE) DLABEL '$X))
|
|
"Now use the DIFF command to differentiate your last result."
|
|
(INCHK (LIST '($DIFF) DLABEL '$X))
|
|
"You may note that the answer MACSYMA just computed is not the same as
|
|
the original expression before it was integrated and
|
|
differentiated. The terms are not expanded, nor is the sum
|
|
put over a common denominator. The RATSIMP (RATional
|
|
SIMPlification) command will do this for you."
|
|
(CMDCHKP (LIST '($RATSIMP) DLABEL))
|
|
"Would you like to learn in more detail about MACSYMA's simplification
|
|
commands?"
|
|
(AND (YESORNO) (SCRIPT '$SIMPLIFICATION NIL))
|
|
"MACSYMA has facilities to handle various series expansions, for
|
|
example, Taylor Series. The TAYLOR command takes four
|
|
arguments, an expression, a variable, the point around which
|
|
to expand the expression, and the power through which to
|
|
generate the terms. To generate a TAYLOR series of the
|
|
square root of 1+X, around the point 0, to the 5th power,
|
|
type:"
|
|
"TAYLOR (SQRT(1+X),X,0,5)"
|
|
|
|
(INCHK '(($TAYLOR) ((%SQRT) ((MPLUS) 1 $X)) $X 0 5))
|
|
|
|
"You can manipulate these expressions just like any others.
|
|
For instance, you can multiply the previous expression by
|
|
itself. Type:"
|
|
"%*%"
|
|
(INCHK (LIST '(MTIMES) DLABEL DLABEL))
|
|
|
|
"The TAYLOR command converts an expression internally
|
|
to MACSYMA's Canonical Rational Expression (CRE) form by
|
|
expanding it and combining all terms over a common denominator.
|
|
This simplifies the operation of the command.
|
|
Expressions that are in CRE form always have the symbol /R/
|
|
following the line label. The RATSIMP command also converts
|
|
expressions internally into CRE form, but converts them back
|
|
to the usual general form at the end.
|
|
Type in:"
|
|
(DISPLA '((MEXPT) ((MPLUS) $X 3) 20))
|
|
(INCHK '((MEXPT) ((MPLUS) $X 3) 20))
|
|
"RATSIMP takes one argument, the expression to be converted.
|
|
Use RATSIMP on the expression you just typed in."
|
|
(CMDCHKP (LIST '($RATSIMP) DLABEL))
|
|
"This form is obviously bulkier than our original expression,
|
|
but the expanded CRE form is useful in many problems."
|
|
"Now, differentiate this expression with respect to X"
|
|
(INCHK (LIST '($DIFF) DLABEL '$X))
|
|
"If you use FACTOR on this expression, you will see that indeed it
|
|
is the appropriate derivative."
|
|
(CMDCHKP (LIST '($FACTOR) DLABEL))
|
|
|
|
"MACSYMA has a facility to solve equations using the SOLVE command, which
|
|
usually takes two arguments, the first an expression, and the second
|
|
the variable to be solved for. The second argument may be
|
|
omitted if the expression contains only one variable.
|
|
Use SOLVE on the following expression:"
|
|
(DISPLA '((MPLUS) ((MEXPT) $X 6) ((MMINUS) 1)))
|
|
(INCHK '(($SOLVE) ((MPLUS) ((MEXPT) $X 6) ((MMINUS) 1))))
|
|
"What would you like to go over now?"
|
|
(PRIMER-SELECT '($SIMPLIFICATION $SCRATCHPAD $ASSIGNMENT $SYNTAX $EXIT)) )
|
|
|
|
(DEFSCRIPT $SIMPLIFICATION
|
|
"This is the SIMPLIFICATION script."
|
|
"MACSYMA has several functions to help simplify expressions. Each
|
|
one of them has special properties which make it useful in
|
|
certain situations."
|
|
"For dealing with ratios of polynomials, there are two
|
|
functions which are of use. These are RATSIMP and
|
|
RATEXPAND. RATSIMP rationally simplifies an expression
|
|
and all of its subexpressions and returns a quotient of
|
|
two polynomials. RATEXPAND is similar
|
|
to EXPAND but the result is a sum of terms each of the form A
|
|
over B with all terms over the least common denominator."
|
|
"Type in a polynomial in X."
|
|
(INCHKP 'POLYCHK)
|
|
"Now use the RATSIMP command on it."
|
|
(CMDCHKP (LIST '($RATSIMP) DLABEL))
|
|
"Sometimes before using RATSIMP on a complicated expression, it is useful
|
|
to cancel common factors and combine terms a bit, to allow RATSIMP
|
|
to work more efficiently."
|
|
"To illustrate this let's make MACSYMA print out the time it uses, by
|
|
setting SHOWTIME to TRUE."
|
|
(MACSYMA '((MSETQ) $SHOWTIME $TRUE))
|
|
"Now type in this expression:"
|
|
(DISPLA SIMPEXAMPLE1)
|
|
(INCHK SIMPEXAMPLE1)(SETQ D DLABEL)
|
|
"And now use RATSIMP on it."
|
|
(CMDCHKP (LIST '($RATSIMP) DLABEL))
|
|
"That works, but for larger expressions it might take quite a long time, or
|
|
might run out of space. XTHRU is a command that will do some
|
|
preliminary simplification like cancelling common factors and
|
|
combining terms. Like RATSIMP, it takes one argument, the
|
|
expression to be operated on.
|
|
So referring back to the original expression
|
|
by its D-label, @D use XTHRU to simplify it."
|
|
(GC)
|
|
(CMDCHKP (LIST '($XTHRU) D))
|
|
"Now use RATSIMP on it."
|
|
(CMDCHKP (LIST '($RATSIMP) DLABEL))
|
|
"As you can see, the total time for the XTHRU and RATSIMP are considerably
|
|
less than that for just the RATSIMP of the original expression."
|
|
"Now, we will turn off the TIME printout again, by setting TIME to FALSE."
|
|
(MACSYMA '((MSETQ) $SHOWTIME $FALSE))
|
|
"Along with FACTOR, EXPAND, RATSIMP, and RATEXPAND,
|
|
MACSYMA also has a simplifier to handle expressions
|
|
involving logs, exponentials, and radicals. This
|
|
simplifier is called RADCAN, which is short for radical
|
|
canonical. RADCAN can take a long time to simplify
|
|
some expressions, so it should be used with this in mind."
|
|
"Would you like to try RADCAN on an expression?"
|
|
(AND (YESORNO) (SCRIPT 'TRYRADCAN NIL))
|
|
"Would you like to learn more about simplifying and manipulating
|
|
expressions?"
|
|
(AND (YESORNO) (SCRIPT '$SCRATCHPAD NIL))
|
|
"What would you like to go over now?"
|
|
(PRIMER-SELECT '($INTRO $SCRATCHPAD $ASSIGNMENT $SYNTAX $EXIT)) )
|
|
|
|
(DEFSCRIPT $SCRATCHPAD
|
|
"This is the SCRATCHPAD script."
|
|
"In some cases the user
|
|
will want to have access to a finer level of control over
|
|
his expressions. MACSYMA has commands which allow the
|
|
user to play with his expressions in the machine in much
|
|
the same way he would with paper and pencil."
|
|
"One important command of this type in MACSYMA is the SUBST
|
|
command. This command can be used to replace all
|
|
occurrences of a subexpression with some other expression
|
|
in an intermediate result. This is useful, for
|
|
example, in expressions involving trigonometric
|
|
functions, where the MACSYMA simplifiers are not willing,
|
|
for reasons of efficiency, to try all possible trigonometric
|
|
identities."
|
|
"SUBST(A,B,C) means substitute A for B in C. The
|
|
resulting expression will be mathematically equivalent to the
|
|
original expression if A is mathematically equivalent to B."
|
|
(SLEEP 2)
|
|
"Here is a simple example of the use of SUBST. The
|
|
numerator of this expression is equal to 1 for all X,
|
|
but the MACSYMA simplifiers will not simplify it directly."
|
|
(MACSYMA SUBST-EXAMPLE1)
|
|
"There are three ways to use SUBST on this example:"
|
|
"One could substitute 1 for SIN(X)^2+COS(X)^2"
|
|
"One could substitute 1-SIN(X)^2 for COS(X)^2"
|
|
"Or one could substitute 1-COS(X)^2 for SIN(X)^2"
|
|
"The first way is more direct, but in more complex
|
|
examples where the sin squared plus cos squared is deeply
|
|
entwined with other elements of the expression the second
|
|
or third way would be necessary. Pick the way you like
|
|
best and simplify the expression by using SUBST."
|
|
(INCHKP 'SUBEXAMPLE1)
|
|
"SUBST however, can only substitute for expressions
|
|
that constitute an extractable part of the larger expression they
|
|
are contained in. In the case where the thing that you
|
|
want to substitute for is embedded in the expression,
|
|
then a more powerful tool is needed. RATSUBST is a
|
|
command that can be helpful in these cases. Here is an
|
|
example of the same simplification as before but with it
|
|
embedded so that the COS(X)^2 is not easily extractable from
|
|
the expression."
|
|
(MACSYMA SUBST-EXAMPLE2)
|
|
"Now use RATSUBST to simplify the above."
|
|
(INCHKP 'SUBEXAMPLE2)
|
|
"In working with algebraic expressions by hand, one will
|
|
often take part of a larger expression and work with that for
|
|
a time. In MACSYMA that can by done by using the PART
|
|
command. The PART command takes two or more arguments.
|
|
The first is the expression and the rest are specifications
|
|
as to which part is to be taken. Each of the specifications
|
|
is an integer that tells which one of the top level operators
|
|
arguments to take. Consider this example:"
|
|
(MACSYMA EXAMPLE3)
|
|
"This is a quotient of sums and thus the quotient is the top
|
|
level operator. Its first argument is its numerator, and its
|
|
second argument is the denominator. Thus:"
|
|
(PCLINE (LIST '($PART) DLABEL 1))
|
|
"would return the numerator. If PART had been given a third
|
|
argument it would pick one of the terms of the numerator. Now
|
|
use the PART command to get the R from the above expression."
|
|
(SETQ $PARTSWITCH T)
|
|
(PARTCHK '$PART '$R)
|
|
(SETQ $PARTSWITCH NIL)
|
|
"What would you like to go over now?"
|
|
(PRIMER-SELECT '($INTRO $SIMPLIFICATION $ASSIGNMENT $SYNTAX $EXIT)) )
|
|
|
|
(DEFSCRIPT $SYNTAX
|
|
"This is the SYNTAX script."
|
|
"Input to MACSYMA is done with a syntax somewhat like that of
|
|
Fortran or Algol. All input lines are terminated
|
|
with a semi-colon (;). Input lines
|
|
are labeled consecutively starting with (C1), and then
|
|
(C2) (C3) etc. MACSYMA results are labeled from
|
|
(D1) on. Thus (D1) is the result of the computations
|
|
performed by MACSYMA on the user's input string (C1)."
|
|
"These line numbers may be used to refer to expressions."
|
|
(SLEEP 2)
|
|
"The display MACSYMA prints out is two dimensional, like a textbook.
|
|
You must be careful not to let this confuse you. If you want
|
|
to type in the mathematical expression 2X, which of course is
|
|
'2 times X', you must type '2*X' even though MACSYMA will
|
|
print back"
|
|
(DISPLA '((MTIMES) 2 $X))
|
|
"Try typing in 2X or some other expression times X:"
|
|
(SYNCHK '(MTIMES) '((MTIMES) 2 $X))
|
|
"* is the multiplication operator. The other operators MACSYMA
|
|
uses are:"
|
|
~! for Factorial,~
|
|
~^ or ** for Exponentiation,~
|
|
~* for Multiplication,~
|
|
~. for non-commutative multiplication~
|
|
~/ for Division, ~
|
|
~+ for Addition, and~
|
|
~- for Subtraction.~
|
|
(SLEEP 2)
|
|
"These operators are applied following the traditional rules for
|
|
operator precedence.
|
|
Do you know what is meant by operator precedence?"
|
|
(AND (NOT (YESORNO)) (SCRIPT 'PRECEDENCE NIL))
|
|
"Variables in MACSYMA (and names of functions and arrays) consist of
|
|
a string of numbers and letters including the character %. Other
|
|
characters may be included by preceding them with a backslash
|
|
(\). Variable names are not limited in length, but must not
|
|
begin with a number."
|
|
"Constants are either numbers or one of the special constants, pi, e
|
|
(the base of natural logarithms), or i (the square root of minus
|
|
one) which are written %PI, %E, and %I to distinguish them from
|
|
the variables pi, e, and i."
|
|
(SLEEP 2)
|
|
"An operator may appear before its argument(s), between its arguments
|
|
or after its argument. Operators that appear before their
|
|
arguments are usually functions (such as SIN and COS) or
|
|
MACSYMA commands (such as INTEGRATE or RATSIMP). The arguments
|
|
to these operators are enclosed in parentheses, for example"
|
|
(PCLINE '((%SIN) 3.141))
|
|
"or"
|
|
(PCLINE '(($INTEGRATE) $% $X))
|
|
"Would you like to practice typing in some expressions?"
|
|
(AND (YESORNO) (SCRIPT 'PRACTICE NIL))
|
|
"That's all for syntax.")
|
|
|
|
(DEFSCRIPT PRACTICE
|
|
"Let's start with a simple linear expression: type in the expression for"
|
|
(DISPLA PRAC-EXAMPLE1)
|
|
|
|
(INCHK PRAC-EXAMPLE1)
|
|
"Okay, now try one where you need to use some parentheses to get the proper
|
|
operator precedence"
|
|
(DISPLA PRAC-EXAMPLE2)
|
|
|
|
(INCHK PRAC-EXAMPLE2)
|
|
"Now try a ratio."
|
|
(DISPLA PRAC-EXAMPLE3)
|
|
|
|
(INCHK PRAC-EXAMPLE3)
|
|
"Okay, try another type of exponentiation"
|
|
(DISPLA PRAC-EXAMPLE4)
|
|
|
|
(INCHK PRAC-EXAMPLE4)
|
|
"Here's a polynomial"
|
|
(DISPLA PRAC-EXAMPLE5)
|
|
|
|
(INCHK PRAC-EXAMPLE5)
|
|
"Now try a slightly more complicated ratio:"
|
|
(DISPLA PRAC-EXAMPLE6)
|
|
|
|
(INCHK PRAC-EXAMPLE6)
|
|
|
|
"Would you like to continue with the Introductory Section of
|
|
the primer?"
|
|
(AND (NOT (YESORNO)) (SCRIPT '$HELP2 NIL)))
|
|
|
|
(DEFSCRIPT $HELP2
|
|
"What would you like to go over? "
|
|
#-Franz
|
|
(PRIMER-SELECT
|
|
'($CONSOLEPRIMER $INTRO $SIMPLIFICATION $SCRATCHPAD $SYNTAX $ASSIGNMENT $EXIT))
|
|
#+Franz
|
|
(PRIMER-SELECT
|
|
'($FRANZPRIMER $INTRO $SIMPLIFICATION $SCRATCHPAD $SYNTAX $ASSIGNMENT $EXIT)))
|
|
|
|
(DEFSCRIPT PRECEDENCE
|
|
"MACSYMA uses the conventional mathematical operator precedence."
|
|
"Would you like to see some examples of how MACSYMA represents
|
|
operator precedence?"
|
|
(AND (YESORNO) (SCRIPT 'PRECEDENCE1 NIL)))
|
|
|
|
(DEFSCRIPT PRECEDENCE1
|
|
"Uparrow, ^, for exponentiation, has higher precedence that * for
|
|
multiplication, so:"
|
|
(MACSYMA '((MTIMES) ((MEXPT) $A 2) $B))
|
|
"Asterisk, *, for multiplication has higher precedence than + for
|
|
addition, so:"
|
|
(MACSYMA '((MPLUS) $A ((MTIMES) $B $C)))
|
|
"Parentheses may be used to change the order of application of
|
|
operators,"
|
|
(MACSYMA '((MTIMES) ((MPLUS) $A $B) $C))
|
|
"If you need further examples, consult the MACSYMA Manual.
|
|
(Page 11 in Version 9, Page 2-4 in Version 10.)"
|
|
(SLEEP 7))
|
|
|
|
(DEFSCRIPT TRYRADCAN
|
|
"Type in this expression:"
|
|
(DISPLA RADCANEXAMPLE)
|
|
(INCHKP 'CHKRADCAN)
|
|
"Now use RADCAN on it."
|
|
(CMDCHKP (LIST '($RADCAN) DLABEL)))
|
|
|
|
(DEFSCRIPT $HELP
|
|
"Hello. Please terminate your responses with a ;.
|
|
What would you like to go over? (Select the number of the script you
|
|
would like to see.)
|
|
INTRO is a general introduction
|
|
for people who have never used MACSYMA or this PRIMER before."
|
|
#-Franz
|
|
(PRIMER-SELECT
|
|
'($CONSOLEPRIMER $INTRO $SIMPLIFICATION $SCRATCHPAD $SYNTAX $ASSIGNMENT $EXIT))
|
|
#+Franz
|
|
(PRIMER-SELECT
|
|
'($FRANZPRIMER $INTRO $SIMPLIFICATION $SCRATCHPAD $SYNTAX $ASSIGNMENT $EXIT)) )
|
|
|
|
(SETQ EXAMPLE1 '((MEXPT) ((MPLUS) $X 1) 3))
|
|
|
|
(SETQ EXAMPLE2 '((MQUOTIENT) $A
|
|
((MPLUS) ((MEXPT) $X 3) ((MTIMES) 2 ((MEXPT) $X 2)) $X)))
|
|
|
|
(SETQ EXAMPLE3 '((MQUOTIENT) ((MPLUS) $A $B $C) ((MPLUS) $Q $R $S)))
|
|
|
|
(SETQ EXAMPLE4 '(($FACTOR)
|
|
((MPLUS) ((MEXPT) $X 3)
|
|
((MTIMES) ((MEXPT) $X 2)
|
|
((MEXPT) $Y 2))
|
|
((MMINUS) ((MTIMES) $X ((MEXPT) $Z 2)))
|
|
((MMINUS) ((MTIMES) ((MEXPT) $Y 2)
|
|
((MEXPT) $Z 2))))))
|
|
|
|
|
|
(SETQ SUBST-EXAMPLE1 '((MQUOTIENT)
|
|
((MPLUS) ((MEXPT) ((%SIN) $X) 2)
|
|
((MEXPT) ((%COS) $X) 2))
|
|
((MPLUS) ((MEXPT) $X 2) 39)))
|
|
|
|
(SETQ SUBST-EXAMPLE2 '((MPLUS)
|
|
((MTIMES) ((MEXPT) ((%COS) $X) 3) ((%SIN) $X))
|
|
((MTIMES) ((%COS) $X) ((MEXPT) ((%SIN) $X) 3))))
|
|
|
|
(SETQ PRAC-EXAMPLE1 '((MPLUS)((MTIMES) 3 $X) 1))
|
|
|
|
(SETQ PRAC-EXAMPLE2 '((MEXPT)((MPLUS) $X 2) 3))
|
|
|
|
(SETQ PRAC-EXAMPLE3 '((MQUOTIENT) 1 ((%SIN) $X)))
|
|
|
|
(SETQ PRAC-EXAMPLE4 '((MEXPT) $%E ((MTIMES) 2 $%PI $%I)))
|
|
|
|
(SETQ PRAC-EXAMPLE5 '((MPLUS)((MEXPT) $X 2)((MTIMES) 2 $X) 1))
|
|
|
|
(SETQ PRAC-EXAMPLE6 '((MQUOTIENT) 1 ((MPLUS) ((MEXPT) $X 2) 3)))
|
|
|
|
(SETQ SIMPEXAMPLE1 '((MPLUS)((MQUOTIENT) 1 ((MEXPT) ((MPLUS) $Y $X) 3))
|
|
((MQUOTIENT) ((MPLUS) ((MEXPT) ((MPLUS) $X 2) 8)
|
|
((MMINUS) ((MTIMES) 2 $Y)))
|
|
((MEXPT) ((MPLUS) $Y $X) 8))))
|
|
|
|
(SETQ RADCANEXAMPLE '((MQUOTIENT)((MEXPT)((MPLUS)
|
|
((%LOG)((MPLUS)((MEXPT) $X 2) $X))
|
|
((MMINUS) ((%LOG) $X)))
|
|
$B)
|
|
((MEXPT)((%LOG)((MPLUS) $X 1))((MQUOTIENT) $B 2))))
|
|
|
|
(DEFUN NUMCHK (NUM)
|
|
(TERPRI)
|
|
(DO ANS (RETRIEVE NIL NIL) (RETRIEVE NIL NIL) NIL
|
|
(COND ((EQ '$NO ANS)
|
|
(TERPRI) (PRINC '|Well, all right, I'll show you.|)
|
|
(TERPRI)(PRIN1 NUM)(PRINC '|;|)(RETURN (TERPRI)))
|
|
((NOT (EQ (TYPEP ANS) 'FIXNUM))
|
|
(TERPRI)(PRINC '|That isn't a number.|)
|
|
(TERPRI)(PRINC '|Try again.|)(TERPRI))
|
|
((AND (> ANS 0)(NOT (> ANS NUM)))(RETURN (TERPRI)))
|
|
(T (TERPRI) (PRINC '|That number isn't in the list. Try again.|)
|
|
(TERPRI)))))
|
|
|
|
(DEFUN QUITCHK ()
|
|
(TERPRI)
|
|
(DO ((X (TYI)(TYI))) (NIL)
|
|
(COND ((OR (= X 103) (= X 71))
|
|
(TERPRI)
|
|
(PRINC '|That was just a G, try again.|)
|
|
(TERPRI)
|
|
(PRINC '|Hold down the control key.|)(TERPRI))
|
|
((= X 7)
|
|
(TERPRI)
|
|
(PRINC '|That's it, very good.|)
|
|
(TERPRI)
|
|
(PRINC '|Now we'll make it a quit character again, so|)
|
|
(TERPRI)
|
|
(PRINC '|only type it if you want to quit out of the PRIMER.|)
|
|
(RETURN (TERPRI)))
|
|
(T (TERPRI)
|
|
(PRINC '|Nope, not quite. Try again, hold down the control key|)
|
|
(TERPRI)
|
|
(PRINC '|and hit the G.|)(TERPRI)))))
|