Boaz Chow <····@usa.pipeline.com> writes:
> I am learning lisp in my school. My first project is to write a lisp
> program to calculate the days between two given months. For example, (days
> 1 jan 31 mar) will give me 29+30+31 which is 90
Since this is an assignment I'm not going to solve it for you, but I
will give you a couple of hints.
> I have done the first part but I don't know how to finish the rest. This
> is my program :
>
> (setq jan (1 31))
> (setq feb (2 30))
> ...
A more useful representation may be to put all the months into a single
list:
(defvar months '((jan 1 31) ...)))
> is there a for-loop in lisp?
There are several iteration constructs in lisp. Look at DOLIST and DO.
> I was working on this program in the computer lab. I was stuck yesterday
> because I lost count of the @·····@% "(" and the ···@!!# ")".
This is the most important suggestion I will give you: Use an editor
that automatically indents your code and automatically balances
parenthesis. When you look at a good lisp program you should be able
to (more or less) ignore the parenthesis and just use the indentation
to indicate control flow.
Kevin Gallagher
________________________________________________________________________
Blackboard Technology Group, Inc. http://www.bbtech.com
401 Main Street Phone: 413-256-8990
Amherst, MA 01002 Fax: 413-256-3179