From: Shirley
Subject: Need help about Union and intersection functional
Date: 
Message-ID: <7c4fa141.0110131807.1963dd97@posting.google.com>
Dear friends,

I'm a beginner at Lisp. I wanna make some function called union and
intersection using cadr and car, but I found it difficult . When we
click on the interpreter icon, it will display a terminal screen with
* as a prompt. If I wanna make or declare the function, in where I
have to type it ? In notepad ??? Can u tell me how to declared the
union and intersection function ???
Eg : * (union "(a b)  '(a b e f))
          (a b e f) ' the result
        * (intersection '(a b d f) '(a c d f g))
          ( a d f) ' the result
Thank you very much

Regards,


Shirley

From: Eric Moss
Subject: Re: Need help about Union and intersection functional
Date: 
Message-ID: <3BC910DD.81CB7EE0@alltel.net>
Shirley wrote:
> 
> Dear friends,
> 
> I'm a beginner at Lisp. I wanna make some function called union and
> intersection using cadr and car, but I found it difficult . When we
> click on the interpreter icon, it will display a terminal screen with
> * as a prompt. If I wanna make or declare the function, in where I
> have to type it ? In notepad ??? Can u tell me how to declared the
> union and intersection function ???
> Eg : * (union "(a b)  '(a b e f))
>           (a b e f) ' the result
>         * (intersection '(a b d f) '(a c d f g))
>           ( a d f) ' the result
> Thank you very much
> 
> Regards,
> 
> Shirley

Do you want to write this as an exercise, or have you not yet found the
built-in functions that do this? If you have the book "Common Lisp,  The
Language" 2nd ed, you will find them on pp. 428 and 429.

In general, the interpreters evaluate a form as soon as it is complete
enough to evaluate, which typically means when the parentheses balance:

(union '(a b c) '(d e f)

) =======> once you enter this balancing paren, your form will be
evaluated.


You can just type in expressions and once they make (enough) sense to
the interpreter, hitting <return> will produce a value or an error. You
can also type expressions into a text file and tell the interpreter to
read and evaluate the contents of that file, but that is what you
usually do after testing your code fragments directly.

One neat thing (among many) is that as you evaluate expressions and
assign the results to variables, e.g. with setq, those creations hang
around so you can test code as you go:

(setq foo '(a b c))
(setq bar '(d e f))
(setq baz (union foo bar)) =========> will evaluate to '(a b c d e f),
                                      though the actual order may vary

baz ================================> returns the already-computed value
of baz.



Have fun,

Eric


-- 
US Supreme Court hearing 00-836
GEORGE W. BUSH, Petitioner, v. PALM BEACH COUNTY CANVASSING BOARD

Justice (Scalia?) to Mr. Klock (representing Katherine Harris):

20 and therefore, I guess, whether we win, whether your side,
21 the side you're supporting wins or loses, it doesn't
22 change that, and I guess that's moot, but my question is,
From: Coby Beck
Subject: Re: Need help about Union and intersection functional
Date: 
Message-ID: <eI7y7.323227$aZ.66647559@typhoon.tampabay.rr.com>
"Shirley" <········@cbn.net.id> wrote in message
·································@posting.google.com...
> Dear friends,
>
> I'm a beginner at Lisp. I wanna make some function called union and
> intersection using cadr and car, but I found it difficult . When we
> click on the interpreter icon, it will display a terminal screen with
> * as a prompt. If I wanna make or declare the function, in where I
> have to type it ? In notepad ??? Can u tell me how to declared the
> union and intersection function ???
> Eg : * (union "(a b)  '(a b e f))
>           (a b e f) ' the result
>         * (intersection '(a b d f) '(a c d f g))
>           ( a d f) ' the result
> Thank you very much
>
> Regards,
>
>
> Shirley
>

Hi Shirley,

A couple of things about your question:  let us know what lisp system you are
using; say up front if this is a homework assignment and post what you have
tried so far so advice can be better directed.

You can type your function definition right at the prompt but if you want to
save it put it in a file with a .lisp or .lsp or .cl extension.  Most
implementations have some kind of editor built in.  How you evaluate the code
in the file is different for different implementations.

Common Lisp has union and intersection so call them something slightly
different (eg my-union..?)

Coby

--
(remove #\space "coby . beck @ opentechgroup . com")
From: Kenny Tilton
Subject: Re: Need help about Union and intersection functional
Date: 
Message-ID: <3BC9AD10.4715E672@nyc.rr.com>
Notepad would work, but you want a Lisp-savvy editor to help with the
parens.  what is the name of the interpreter? is there a 'file' menu?
try "New", it might open up a built-in editor.

kenny
clinisys

Shirley wrote:
> 
> Dear friends,
> 
> I'm a beginner at Lisp. I wanna make some function called union and
> intersection using cadr and car, but I found it difficult . When we
> click on the interpreter icon, it will display a terminal screen with
> * as a prompt. If I wanna make or declare the function, in where I
> have to type it ? In notepad ??? Can u tell me how to declared the
> union and intersection function ???
> Eg : * (union "(a b)  '(a b e f))
>           (a b e f) ' the result
>         * (intersection '(a b d f) '(a c d f g))
>           ( a d f) ' the result
> Thank you very much
> 
> Regards,
> 
> Shirley