From: Jim Morrison
Subject: newbie help
Date: 
Message-ID: <3E7AAC32.5050507@attbi.com>
Hello,

This is a school assignment.  I have a small program here:

(set 'mytree '((((A B C) D (E F G)) H ((I J K) L (M N O))) P (((Q R S) T
(U V W)) X (Y Z nil))))

(defun preorder (x)
  (cond ((atom x) x)
        ((null (car x)) nil )
        ((listp x) (preorder (car x)) (preorder (cdr x)) ) ) )

(preorder mytree)

I'v saved it into a file called lab.lisp

so then I do
 >lisp -load lab.lisp

First I got error messages and I fixed those errors.  
Now that errors are fixed I get nothing but * prompt.

If i type (preorder mytree) I get NIL.

So now I have no idea what to do next, how can I 'step' through preorder 
to see what is happening???

Jim
From: Erann Gat
Subject: Re: newbie help
Date: 
Message-ID: <gat-2103030051300001@192.168.1.51>
In article <················@attbi.com>, ······@attbi.com wrote:

> Hello,
> 
> This is a school assignment.  I have a small program here:
> 
> (set 'mytree '((((A B C) D (E F G)) H ((I J K) L (M N O))) P (((Q R S) T
> (U V W)) X (Y Z nil))))
> 
> (defun preorder (x)
>   (cond ((atom x) x)
>         ((null (car x)) nil )
>         ((listp x) (preorder (car x)) (preorder (cdr x)) ) ) )
> 
> (preorder mytree)
> 
> I'v saved it into a file called lab.lisp
> 
> so then I do
>  >lisp -load lab.lisp
> 
> First I got error messages and I fixed those errors.  

What error messages did you get, and how did you fix them?

> Now that errors are fixed I get nothing but * prompt.
> 
> If i type (preorder mytree) I get NIL.
> 
> So now I have no idea what to do next, how can I 'step' through preorder 
> to see what is happening???

Try:

(trace preorder)

Also:

       ((listp x) (preorder (car x)) (preorder (cdr x)) ) ) )

If this branch of the COND is executed then it will compute (preorder (car
x)) and then throw the result away before computing (preorder (cdr x)). 
That is probably not what you want.  :-)

E.