From: The Joelman
Subject: Re: Newbie - construct a nested list?
Date: 
Message-ID: <Pine.SGI.3.91.950924143338.10496A-100000@umbc8.umbc.edu>
On Sun, 24 Sep 1995, Tim Pierce wrote:

> In article <·······································@umbc8.umbc.edu> you write:
> 
> >Here's what I want:
> >
> >L = (((A (B C)) C))
> >
> >I tried it with (setq L '(((A(B C))C)) )
> >but it is counting this whole thing as the one element of L.
> 
> Well, that's correct.  L is a list of one element -- that's what
> you wrote above.  What is it not doing that you think it should?
> 

Okay, I'm passing this list to a fuction I wrote which determines if an 
S-expression is a member of a list but it goes through all levels of the 
list.  So I'm feeding it the above list an a 'B or something.  

Here's my function:

(defun mem-g (S1 S2)
	(cond ((null S1) NIL)
	      ((equal S2 (car S1)) (car S1))
	      ((atom (car S1)) (mem-g ((cdr S1) S2)))
	      ((listp (car S1)) (mem-g ((car S1) S2)))
	)
)

When I pass it that list like this (mem-g '(((A (B C)) C)) 'B)
	I get a bad function (car s1) from the interpreter. I figured
	I wasn't forming the list correctly.  But maybe I'm missing 
something in my function above (since that's where the interpreter is
	telling me there's an error).


Also, I thought I found the better way to build this nested list with..
	(setq M (cons (cons (cons 'A (cons 'B 'C) ) 'C) nil) )
but that gave me...
	(((a b . c) . c))
So what's with those dots???


I'm using xlisp for Macintosh, if that makes any difference, and it 
shouldn't I don't think.

If you have any advice it'd be much appreciated.

Alive and well and Power Mac native,
-Joel
   _____________________________________________________________________
   | University of Maryland,   |  UMBC Macintosh User Group            |
   |       Baltimore County    |  http://umbc.edu/~jwisne1/mug         |
   | Computer Science Major    |  Read News at: umbc.org.mug           |
   | ·······@umbc.edu          |       ** Clinton/Gore in `96 **       |
   | http://umbc.edu/~jwisne1  |   Give me liberals or give me death!  | 
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^