From: Emre Sevinc
Subject: To be or not to be: the way of Lisp
Date: 
Message-ID: <87k6f374h4.fsf@ileriseviye.org>
Just another way to explore the meaning of life [1] using the Lisp way:

(format t "Shakespeare has given us the age-old question, \"To be or not to be?\" 
Computer science has given us the answer:~%
~x | ~~~x == ~x" #x2B #x2B (ldb (byte 8 0) (logior #x2B (lognot #x2B))))


1- "How not to program in C++" by Steve Qualline, page 164.


PS: Hmm, do we need a book "How not to program in Lisp", or not?

-- 
Emre Sevinc

eMBA Software Developer         Actively engaged in:
http:www.bilgi.edu.tr           http://ileriseviye.org
http://www.bilgi.edu.tr         http://fazlamesai.net
Cognitive Science Student       http://cazci.com
http://www.cogsci.boun.edu.tr

From: verec
Subject: Re: To be or not to be: the way of Lisp
Date: 
Message-ID: <4380f72f$0$38038$5a6aecb4@news.aaisp.net.uk>
On 2005-11-20 14:56:23 +0000, Emre Sevinc <·····@bilgi.edu.tr> said:

> (format t "Shakespeare has given us the age-old question, \"To be or 
> not to be?\" Computer science has given us the answer:~%
> ~x | ~~~x == ~x" #x2B #x2B (ldb (byte 8 0) (logior #x2B (lognot #x2B))))

Stupid me! I was expecting 42!

:-)
-- 
JFB  ()
From: Rob Warnock
Subject: Re: To be or not to be: the way of Lisp
Date: 
Message-ID: <b5qdnR2zyKaQKBzeRVn-sQ@speakeasy.net>
verec  <·····@mac.com> wrote:
+---------------
| Emre Sevinc <·····@bilgi.edu.tr> said:
| > (format t "Shakespeare has given us the age-old question, \"To be or 
| > not to be?\" Computer science has given us the answer:~%
| > ~x | ~~~x == ~x" #x2B #x2B (ldb (byte 8 0) (logior #x2B (lognot #x2B))))
| 
| Stupid me! I was expecting 42!
+---------------

Off by one; #x2A is the answer to "Life, the Universe, and Everything".


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Raffael Cavallaro
Subject: Re: To be or not to be: the way of Lisp
Date: 
Message-ID: <2005112120521775249%raffaelcavallaro@pasdespamsilvousplaitmaccom>
On 2005-11-21 06:52:45 -0500, ····@rpw3.org (Rob Warnock) said:

> Off by one; #x2A is the answer to "Life, the Universe, and Everything".

CL-USER> (or #x2b (not #x2b))
43

but...

CL-USER> (logior #x2B (lognot #x2B))
-1

however, if we combine these two approaches...


CL-USER> (+ (or #x2b (not #x2b)) (logior #x2B (lognot #x2B)))
42

Coincidence? I think not ;^)
From: Emre Sevinc
Subject: Re: To be or not to be: the way of Lisp
Date: 
Message-ID: <87hda65fgk.fsf@ileriseviye.org>
>>>>> "verec" == verec  <·····@mac.com> writes:

    verec> On 2005-11-20 14:56:23 +0000, Emre Sevinc
    verec> <·····@bilgi.edu.tr> said:
    >> (format t "Shakespeare has given us the age-old question, \"To
    >> be or not to be?\" Computer science has given us the answer:~%
    >> ~x | ~~~x == ~x" #x2B #x2B (ldb (byte 8 0) (logior #x2B (lognot
    >> #x2B))))

    verec> Stupid me! I was expecting 42!

That's what many of my fellow programmers (who read Douglas Adams)
said :)


-- 
Emre Sevinc

eMBA Software Developer         Actively engaged in:
http:www.bilgi.edu.tr           http://ileriseviye.org
http://www.bilgi.edu.tr         http://fazlamesai.net
Cognitive Science Student       http://cazci.com
http://www.cogsci.boun.edu.tr
From: Lars Brinkhoff
Subject: Re: To be or not to be: the way of Lisp
Date: 
Message-ID: <85br0egrh6.fsf@junk.nocrew.org>
Emre Sevinc <·····@bilgi.edu.tr> writes:
> Just another way to explore the meaning of life [1] using the Lisp way:
> (format t "Shakespeare has given us the age-old question, 
>            \"To be or not to be?\" 
>            Computer science has given us the answer:~%
>            ~x | ~~~x == ~x"
>         #x2B #x2B (ldb (byte 8 0) (logior #x2B (lognot #x2B))))

Do you mean that the book contained this Lisp snippet (which seems
unlikely but nice), or did you translate it from C++?

> 1- "How not to program in C++" by Steve Qualline, page 164.

His name appears to be Steve Oualline:

http://www.oualline.com/
From: Emre Sevinc
Subject: Re: To be or not to be: the way of Lisp
Date: 
Message-ID: <87d5ku5exd.fsf@ileriseviye.org>
>>>>> "LB" == Lars Brinkhoff <·········@nocrew.org> writes:

    LB> Emre Sevinc <·····@bilgi.edu.tr> writes:
    >> Just another way to explore the meaning of life [1] using the
    >> Lisp way: (format t "Shakespeare has given us the age-old
    >> question, \"To be or not to be?\" Computer science has given us
    >> the answer:~% ~x | ~~~x == ~x" #x2B #x2B (ldb (byte 8 0)
    >> (logior #x2B (lognot #x2B))))

    LB> Do you mean that the book contained this Lisp snippet (which
    LB> seems unlikely but nice), or did you translate it from C++?

Neither one. The book just contained [1]:

  Shakespeare has given us the age-old question, "To be or not to be?"
  Computer science has given us the answer: "FF".

   0x2B | ~0x2B == FF

Well, I must admit that my first reaction was to write a 
short code in C and compile it with gcc. After that I tried
it with Lisp but without using (ldb (byte 8 0) ...
I couldn't get the FF result I wanted (I got -1). Finally
I came up with the code you see.

    >> 1- "How not to program in C++" by Steve Qualline, page 164.
    LB> His name appears to be Steve Oualline:
    LB> http://www.oualline.com/

Opps, you're right, my mistake! Sorry.


1- http://books.google.com/books?hl=en&id=wgwE0dQ15xEC&pg=PA164&lpg=PA164&dq=shakespeare+Computer+science+has+given+us+the+answer&prev=http://books.google.com/books%3Fq%3Dshakespeare%2BComputer%2Bscience%2Bhas%2Bgiven%2Bus%2Bthe%2Banswer%26lr%3D%26client%3Dfirefox-a&sig=KElCnNfr6jUYieU4NIw9CcWUGQk

-- 
Emre Sevinc

eMBA Software Developer         Actively engaged in:
http:www.bilgi.edu.tr           http://ileriseviye.org
http://www.bilgi.edu.tr         http://fazlamesai.net
Cognitive Science Student       http://cazci.com
http://www.cogsci.boun.edu.tr
From: Marcin 'Qrczak' Kowalczyk
Subject: Re: To be or not to be: the way of Lisp
Date: 
Message-ID: <87psouvzah.fsf@qrnik.zagroda>
Emre Sevinc <·····@bilgi.edu.tr> writes:

>   Shakespeare has given us the age-old question, "To be or not to be?"
>   Computer science has given us the answer: "FF".
>
>    0x2B | ~0x2B == FF
>
> Well, I must admit that my first reaction was to write a 
> short code in C and compile it with gcc. After that I tried
> it with Lisp but without using (ldb (byte 8 0) ...
> I couldn't get the FF result I wanted (I got -1).

Because the result *is* -1, unless you artificially take only 8 bits
of it and treat them as unsigned.

-- 
   __("<         Marcin Kowalczyk
   \__/       ······@knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/
From: Emre Sevinc
Subject: Re: To be or not to be: the way of Lisp
Date: 
Message-ID: <874q6659vt.fsf@ileriseviye.org>
>>>>> "MK" == Marcin 'Qrczak' Kowalczyk <······@knm.org.pl> writes:

    MK> Emre Sevinc <·····@bilgi.edu.tr> writes:
    >> Shakespeare has given us the age-old question, "To be or not to
    >> be?"  Computer science has given us the answer: "FF".
    >> 
    >> 0x2B | ~0x2B == FF
    >> 
    >> Well, I must admit that my first reaction was to write a short
    >> code in C and compile it with gcc. After that I tried it with
    >> Lisp but without using (ldb (byte 8 0) ...  I couldn't get the
    >> FF result I wanted (I got -1).

    MK> Because the result *is* -1, unless you artificially take only
    MK> 8 bits of it and treat them as unsigned.

You're right, it is. The only thing is that I just couldn't
find quickly the way to treat it as an unsigned 8-bit quantity.
Wandering around CLHS or CLtL2 didn't produce any quick results
and for the first time in my life I heard of a concept called
"bit weight" (which I'm trying to understand).

BTW I believe that treating the result as -1 is THE artifical
viewpoint, a method that is used as an interpretation for
negative numbers. Unless you interpret it, it is nothing but
1s and 0s right?

I was happy that #lisp existed on irc.freenode.net ;-) Sometimes
a NII (natural intelligence interfece) to something like CLHS
is a real helper (of course I don't deny that true understanding
doesn't come from quick solutions but from detailed study of specification
and experimenting, but that's another story).

1- ...byte returns a byte specifier that indicates a byte of width size 
and whose *bits have weights* 2^position + size - 1 through 2^position,...

-- 
Emre Sevinc

eMBA Software Developer         Actively engaged in:
http:www.bilgi.edu.tr           http://ileriseviye.org
http://www.bilgi.edu.tr         http://fazlamesai.net
Cognitive Science Student       http://cazci.com
http://www.cogsci.boun.edu.tr
From: Emre Sevinc
Subject: Re: To be or not to be: the way of Lisp
Date: 
Message-ID: <878xvi5eaz.fsf@ileriseviye.org>
>>>>> "LB" == Lars Brinkhoff <·········@nocrew.org> writes:

    LB> Emre Sevinc <·····@bilgi.edu.tr> writes:
    >> Just another way to explore the meaning of life [1] using the
    >> Lisp way: (format t "Shakespeare has given us the age-old
    >> question, \"To be or not to be?\" Computer science has given us
    >> the answer:~% ~x | ~~~x == ~x" #x2B #x2B (ldb (byte 8 0)
    >> (logior #x2B (lognot #x2B))))

    LB> Do you mean that the book contained this Lisp snippet (which
    LB> seems unlikely but nice), or did you translate it from C++?

And Oualline adds:

"Most of the time when I tell this joke to non-technical people
they just look at me strangely. Technical people tend to think
for a minute and then say, "You're right." Only one person
in about a hundred actually laughs." 


-- 
Emre Sevinc

eMBA Software Developer         Actively engaged in:
http:www.bilgi.edu.tr           http://ileriseviye.org
http://www.bilgi.edu.tr         http://fazlamesai.net
Cognitive Science Student       http://cazci.com
http://www.cogsci.boun.edu.tr
From: justinhj
Subject: Re: To be or not to be: the way of Lisp
Date: 
Message-ID: <1132592719.504253.65940@g44g2000cwa.googlegroups.com>
Emre Sevinc wrote:
> >>>>> "LB" == Lars Brinkhoff <·········@nocrew.org> writes:
>
>     LB> Emre Sevinc <·····@bilgi.edu.tr> writes:
>     >> Just another way to explore the meaning of life [1] using the
>     >> Lisp way: (format t "Shakespeare has given us the age-old
>     >> question, \"To be or not to be?\" Computer science has given us
>     >> the answer:~% ~x | ~~~x == ~x" #x2B #x2B (ldb (byte 8 0)
>     >> (logior #x2B (lognot #x2B))))
>
>     LB> Do you mean that the book contained this Lisp snippet (which
>     LB> seems unlikely but nice), or did you translate it from C++?
>
> And Oualline adds:
>
> "Most of the time when I tell this joke to non-technical people
> they just look at me strangely. Technical people tend to think
> for a minute and then say, "You're right." Only one person
> in about a hundred actually laughs."
>
>
> --
> Emre Sevinc
>
> eMBA Software Developer         Actively engaged in:
> http:www.bilgi.edu.tr           http://ileriseviye.org
> http://www.bilgi.edu.tr         http://fazlamesai.net
> Cognitive Science Student       http://cazci.com
> http://www.cogsci.boun.edu.tr

In C...

#define QUESTION (0x2b | ~0x2b)