From: fokchi
Subject: a simple question!
Date: 
Message-ID: <3446887C.F7C717AC@isu.edu>
Hi,

I don't know much about lisp. And I want to do a question on lisp as
follows. Can anyone help me with this question?

I want to write a function to prints it out in dot notation:

>(showdots '(x y z))
And the output should look like this:
(X . (Y . (Z . NIL)))
NIL

I am looking forward to hearing from you! Thanks.


Ann
From: Barry Margolin
Subject: Re: a simple question!
Date: 
Message-ID: <6267j0$rme@tools.bbnplanet.com>
In article <·················@isu.edu>, fokchi  <······@isu.edu> wrote:
>I don't know much about lisp. And I want to do a question on lisp as
>follows. Can anyone help me with this question?

Why do you need to do this?

>I want to write a function to prints it out in dot notation:
>
>>(showdots '(x y z))
>And the output should look like this:
>(X . (Y . (Z . NIL)))
>NIL

(defun showdots (list)
  (if (null list) (format t "~S" list)
      (progn (format t "(~S . " (car list))
             (showdots (cdr list))
             (format t ")"))))

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
Support the anti-spam movement; see <http://www.cauce.org/>
Please don't send technical questions directly to me, post them to newsgroups.