From: Jeff Sandys
Subject: Re: Still a Newbie - Existence in a list?
Date: 
Message-ID: <3C9B9358.88F65CED@juno.com>
TejimaNoHimitsu wrote:
> 
> I could do (member 'b '(a b c)) but what about ... 
> '(b a (t y (q w (z c)) v) d)  and I wanted to check ... v 

flatten is a useful function to learn how to write.
(flatten '(b a (t y (q w (z c)) v) d)) is '(b a t y q w z c v d)
Then you can use (member 'v (flatten '(b a (t y (q w (z c)) v) d)))

Thanks,
Jeff Sandys

From: Kent M Pitman
Subject: Re: Still a Newbie - Existence in a list?
Date: 
Message-ID: <sfwbsdg1fv3.fsf@shell01.TheWorld.com>
Jeff Sandys <·······@juno.com> writes:

> TejimaNoHimitsu wrote:
> > 
> > I could do (member 'b '(a b c)) but what about ... 
> > '(b a (t y (q w (z c)) v) d)  and I wanted to check ... v 
> 
> flatten is a useful function to learn how to write.

Though rarely a useful one to need to call.

> (flatten '(b a (t y (q w (z c)) v) d)) is '(b a t y q w z c v d)
> Then you can use (member 'v (flatten '(b a (t y (q w (z c)) v) d)))

Sort of like the way you test whether a certain file occurs in your file
system by first moving all the files in the file system to a single folder
and then searching "just" that one folder.
From: Joe Marshall
Subject: [NOISE]Re: Still a Newbie - Existence in a list?
Date: 
Message-ID: <QINm8.36327$44.11594855@typhoon.ne.ipsvc.net>
"Kent M Pitman" <······@world.std.com> wrote in message
····················@shell01.TheWorld.com...
> Jeff Sandys <·······@juno.com> writes:
> >
> > flatten is a useful function to learn how to write.
>
> Though rarely a useful one to need to call.
>
> > (flatten '(b a (t y (q w (z c)) v) d)) is '(b a t y q w z c v d)
> > Then you can use (member 'v (flatten '(b a (t y (q w (z c)) v) d)))
>
> Sort of like the way you test whether a certain file occurs in your file
> system by first moving all the files in the file system to a single folder
> and then searching "just" that one folder.

That uses up too much disk space.  Do this:

(tar cof -) | (tar tf -) | grep
From: Daniel Barlow
Subject: Re: Still a Newbie - Existence in a list?
Date: 
Message-ID: <87r8mcb2z7.fsf@noetbook.telent.net>
Kent M Pitman <······@world.std.com> writes:

> Sort of like the way you test whether a certain file occurs in your file
> system by first moving all the files in the file system to a single folder
> and then searching "just" that one folder.

And if two of the files have the same name?  There's a point to be
made here about object identity ;-)


-dan

-- 

  http://ww.telent.net/cliki/ - Link farm for free CL-on-Unix resources 
From: Eric Moss
Subject: Re: Still a Newbie - Existence in a list?
Date: 
Message-ID: <86wuw4ggsw.fsf@kirk.localdomain>
>And if two of the files have the same name?  There's a point to be
>made here about object identity ;-)

Maybe we should call directories 'packages' instead.  Or would that be the
other way around? :)

Eric
From: Kenny Tilton
Subject: Re: Still a Newbie - Existence in a list?
Date: 
Message-ID: <3C9BD2B2.BC150EC3@nyc.rr.com>
Kent M Pitman wrote:
> 
> Jeff Sandys <·······@juno.com> writes:
> 
> > TejimaNoHimitsu wrote:
> > >
> > > I could do (member 'b '(a b c)) but what about ...
> > > '(b a (t y (q w (z c)) v) d)  and I wanted to check ... v
> >
> > flatten is a useful function to learn how to write.
> 
> Though rarely a useful one to need to call.

I have a great use for it: I know a group widget's contained widgets
must always be in a flat list (cuz I built it dat way). So a wodge of
code meant to return those widgets can return them in any tree structure
it likes (including with nils where the code decides not to make a
widget), then my packed-flat! function tidies everything up.

it's tremendously relaxing knowing I can return widgets and nils left
and right in any nested list structure and have pf! mop up.

Not that one would want to solve the OP problem by flattening the search
domain, of course.

-- 

 kenny tilton
 clinisys, inc
 ---------------------------------------------------------------
"Harvey has overcome not only time and space but any objections."
                                                        Elwood P. Dowd
From: Thomas A. Russ
Subject: Re: Still a Newbie - Existence in a list?
Date: 
Message-ID: <ymi4rj4e8d8.fsf@sevak.isi.edu>
TejimaNoHimitsu wrote:
> 
> I could do (member 'b '(a b c)) but what about ... 
> '(b a (t y (q w (z c)) v) d)  and I wanted to check ... v 

Of course, you could also write a simple find-in-tree function yourself.
It shouldn't be too difficult.  One example would be:

  (defun find-in-tree (item tree)
    ;; Return true if "item" can be found within "tree";
    ;; This assumes true lists, i.e., no dotted pairs.
    (or (eql item tree)
        (and (consp tree)
	     (loop for clause in tree
	           thereis (find-in-tree item clause))) ))



-- 
Thomas A. Russ,  USC/Information Sciences Institute          ···@isi.edu    
From: Wolfhard Buß
Subject: Re: Still a Newbie - Existence in a list?
Date: 
Message-ID: <m3r8m6f93q.fsf@buss-14250.user.cis.dfn.de>
···@sevak.isi.edu (Thomas A. Russ) writes:

>   (defun find-in-tree (item tree)
>     ;; Return true if "item" can be found within "tree";
>     ;; This assumes true lists, i.e., no dotted pairs.
>     (or (eql item tree)
>         (and (consp tree)
> 	     (loop for clause in tree
> 	           thereis (find-in-tree item clause))) ))

Just for the record a variation that works for _all_ kinds
of trees:

 (defun find-in-tree (item tree)
   (or (eql item tree)
       (and (consp tree)
            (loop for (first . rest) = tree then rest
                  thereis (find-in-tree item first)
                  when (atom rest)
                    return  (find-in-tree item rest)))))

-- 
"Das Auto hat keine Zukunft. Ich setze aufs Pferd."  Wilhelm II. (1859-1941)