From: Thomas C Wilson
Subject: Hel needed with first ever LISP homework?
Date: 
Message-ID: <Pine.HPP.3.95.970120173919.19412A-100000@nsccux.sccd.ctc.edu>
Hi: I'm kinda new at this newsgroup thing, but, I am having trouble
getting my first homework (from the insuctor) to even load (:ld pr2a.lisp)
into the (cl) environment.  So I thought I would post this message and
check back later this evening and see if someone commented on it?

Here is what the assignment looked like:
this will give you a head start on your first lisp assignments.
The projects will be discussed in class, and we will go over the basics
of lisp in class.


CSE 415      Programming Project #2          (due  Friday, Jan  31)


        The following lisp function , D, has two arguments, E and x.   E
is a fully
parenthesized expression with binary operators and a variable, x.  
Operators and arguments are in Rlisp formatS with the operator first, then
the
arguments, with enclosing parentheses. For example,  (+ x 3) represents
the
sum of x and 3.
        This function computes the symbolic derivative of E with respect
to x.  The
call,  (D  T(+ x 3)  Tx ) would return the value,  1.  

(defun D (E x)
        (cond (( atom E) (cond  ((equal E x)  1 )  ( T  0) ))

                ((or (equal (op E)  '+ ) (equal (op E) '-))
                '(, (op E),  (D  (arg1 E) x)  , (D  (arg2 E) x)))

                ((equal (op E )  '*)
                        '(+(*,(arg1 E), (D (arg2 E) x) )
                           (*,(arg2 E), (D (arg1 E) x )))
                                                        ))

        This function allows only the operators, +, -, and *

       (a)   Add to the function, so that the operators, / and exp will be
        included. Note that exp is restricted so that the exponent is
        an integer.

        Run your function, with the call:

                (D  '(/  (+  (exp  x  2)  2)  (*  5  x) )    'x  )


(b)      This function also will do multiple partial derivatives, with
multiple calls. eg if E were given a value,  
(setf  E  T(*  x  (exp  y  2 ) ) ) , the call (D   (D  E   Tx)   Ty) would
return the second derivative of E with respect to  x and y, giving the
result,   (*  2   y  )

[The actual result will be messier than this but it will be equivalent.]

*******************  Student talking now.
So I cut and paste this into a file, then try to load it into LISP.
First I got errors about "commas not inside back quotes" so I changed the
single quotes to back quotes.

Then I got too may ")".

Then after some conversations I made three other (defun)'s for
1.  op E
2.  arg1 E
3.  arg2 E

now I have this:
(defun op (Expr)
        (first Expr))

(defun arg1 (Expr)
        (second Expr))

(defun arg2 (Expr)
        (Third Expr))

(defun D (E x)
        (cond (( atom E) (cond  ((equal E x)  1 )  ( T  0) ))

                ((or (equal (op E)  '+ ) (equal (op E) '-))
                `(, (op E),  (D  (arg1 E) x)  , (D  (arg2 E) x)))

                ((equal (op E )  '*)
                        `(+(*,(arg1 E), (D (arg2 E) x) )
                           (*,(arg2 E), (D (arg1 E) x )))
                                                        )) 
"Here is what I'm geting now."

USER(1): :ld pr2a.txt
; Loading /user4/tomwil/pr2a.txt.
Error: eof encountered on stream
       #<EXCL::CHARACTER-INPUT-FILE-STREAM "/user4/tomwil/pr2a.txt" pos
520 @
         #x106788f2>
  [condition type: END-OF-FILE]

Restart actions (select using :continue):
 0: retry the load of pr2a.txt
[1] USER(2):

Any relevant suggestions welcome.
Thanks sooo much if you read this far. (can you help?)
---------------------------------------------------------------------
Tom Wilson E-mail me at ······@nsccux.sccd.ctc.edu
Student at North Seattle Com. Col. /Comp. Sci.
http://nsccux.sccd.ctc.edu/~wilson
······@u.washington.edu

"When the code and the comments disagree, both are probably wrong"
						-Norm Schryer.
--------------------------------------------------------------------

From: Espen Vestre
Subject: Re: Hel needed with first ever LISP homework?
Date: 
Message-ID: <w6iv4rnxdb.fsf@opus.online.no>
Thomas C Wilson <······@nsccux.sccd.ctc.edu> writes:

> "Here is what I'm geting now."
> 
> USER(1): :ld pr2a.txt
> ; Loading /user4/tomwil/pr2a.txt.
> Error: eof encountered on stream
>        #<EXCL::CHARACTER-INPUT-FILE-STREAM "/user4/tomwil/pr2a.txt" pos
> 520 @
>          #x106788f2>
>   [condition type: END-OF-FILE]

A right parenthesis is missing!

You should edit your programs in a lisp-aware editor which
counts the parens for you.

Actually, it should be part of your lisp course that you start 
working in a lisp-aware editing environment right away!  (I have
very good experience with letting students without any computer
experience start with Macintosh Common Lisp, which has an Emacs-
like editor - *and* a similar Listener with both paren-match
indication and Minibuffer indication of function syntax.)

--

regards,
  Espen Vestre
  Telenor Online AS
From: Erik Naggum
Subject: Re: Hel needed with first ever LISP homework?
Date: 
Message-ID: <3062850735931065@naggum.no>
* Thomas C. Wilson
| USER(1): :ld pr2a.txt
| ; Loading /user4/tomwil/pr2a.txt.
| Error: eof encountered on stream
|        #<EXCL::CHARACTER-INPUT-FILE-STREAM "/user4/tomwil/pr2a.txt" pos
| 520 @
|          #x106788f2>
|   [condition type: END-OF-FILE]
| 
| Restart actions (select using :continue):
|  0: retry the load of pr2a.txt
| [1] USER(2):
| 
| Any relevant suggestions welcome.
| Thanks sooo much if you read this far. (can you help?)

you're obviously using Allegro Common Lisp from Franz.  you should not be
using Allegro from the command line, but from the very good Emacs interface
supplied by Franz.  you start up Allegro under Emacs with the command M-x
fi:common-lisp RET, and answer the questions.  if you are not familiar with
Emacs, your instructor failed to make that a prerequisite for the course.

set the Emacs variable fi:check-unbalanced-parentheses-when-saving to t,
and visit the file.  make a trivial change, then save it.  fix the problem
that Emacs complains about, then save again.

by the way, Lisp files should end in .cl or .lisp or .lsp.  that way, Emacs
and the Franz Inc (fi) package will detect that you have Lisp code and do
the right thing.

good luck.

#\Erik
-- 
1,3,7-trimethylxanthine -- a basic ingredient in quality software.