From: chico
Subject: is-semicolumns function
Date: 
Message-ID: <454bb448$0$18554$5fc30a8@news.tiscali.it>
Hi all,
I'm building a function that returns T if the passed char is a semicolumns.

(defun is-columns (c)
(cond ((char-equal c #\;) t)))

Obviously it doesn't work because ; means beginning of comments...
Does someone have some ideas?

Thanks,
Pietro

From: ········@gmail.com
Subject: Re: is-semicolumns function
Date: 
Message-ID: <1162589525.615364.286140@m73g2000cwd.googlegroups.com>
> Obviously it doesn't work because ; means beginning of comments...
> Does someone have some ideas?

Sure it does:

<2>> (defun is-columns (c)
(cond ((char-equal c #\;) t)))
:: IS-COLUMNS
<3>> (is-columns #\;)
:: T

This probably isn't that you had intended. What did you intend? What's
your high level goal?

(BTW, it's "semicolon", not "semicolumn".)
From: chico
Subject: Re: is-semicolumns function
Date: 
Message-ID: <454bb921$0$21812$5fc30a8@news.tiscali.it>
········@gmail.com ha scritto:
>> Obviously it doesn't work because ; means beginning of comments...
>> Does someone have some ideas?
> 
> Sure it does:
> 
> <2>> (defun is-columns (c)
> (cond ((char-equal c #\;) t)))
> :: IS-COLUMNS
> <3>> (is-columns #\;)
> :: T
> 
> This probably isn't that you had intended. What did you intend? What's
> your high level goal?
> 
> (BTW, it's "semicolon", not "semicolumn".)
> 

Well.... I cover myself in shame, I didn't try the function because i 
saw on the editor that the rest of the line was commented.... only a 
visualization problem.
I asked because I was quite sure that there some special combination of 
caracter to represent special caracter.
PS: thanks for the correction of the word, that's why I couldn't find 
anything on the web ROTFL ....as you can see I'm not Engligh

Thanks,
Bye
From: ········@gmail.com
Subject: Re: is-semicolumns function
Date: 
Message-ID: <1162593277.481156.180160@m73g2000cwd.googlegroups.com>
> Well.... I cover myself in shame, ...

Don't worry about it. I cover myself in shame on a regular basis! (In
fact, I did it just last night in another thread involving logos! :-)

BTW, you don't need to do quite that complex a test. Since there's only
one condition, you don't need the COND at all. You can just write:

  (defun is-semicolon (char)
     (char-equal #\; char))

So if this is really what you are trying to do, you probably don't need
a new function at all, since it's not saving you much in typing or
clarity, and it's costing you (a very tiny bit of) function call time.

> PS: thanks for the correction of the word, that's why I couldn't find
> anything on the web ROTFL ....as you can see I'm not Engligh

Yes, I can tell. Not a problem as long as you don't try to type "lithp"
:-)
From: Pascal Bourguignon
Subject: Re: is-semicolumns function
Date: 
Message-ID: <874ptgqf0e.fsf@thalassa.informatimago.com>
·········@gmail.com" <········@gmail.com> writes:

>> Well.... I cover myself in shame, ...
>
> Don't worry about it. I cover myself in shame on a regular basis! (In
> fact, I did it just last night in another thread involving logos! :-)
>
> BTW, you don't need to do quite that complex a test. Since there's only
> one condition, you don't need the COND at all. You can just write:
>
>   (defun is-semicolon (char)
>      (char-equal #\; char))

Well, the requirements were to return T if char was a semicolon, not
true.  And since there are no upper case or lower case semicolons, you
don't need to test for both.  Also, the convention is to use p or -p
for predicates (-p when the predicate name is multi-word).  Summing it
all:

(defun semicolonp (char) (not (not (char= #\; char))))

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

Nobody can fix the economy.  Nobody can be trusted with their finger
on the button.  Nobody's perfect.  VOTE FOR NOBODY.
From: ········@gmail.com
Subject: Re: is-semicolumns function
Date: 
Message-ID: <1162749321.953985.307260@k70g2000cwa.googlegroups.com>
> (defun semicolonp (char) (not (not (char= #\; char))))

Okay, good points about the case and requirements. Not to be obsessive
or anything, but I find NOT NOT to be a tad obscure. (And the -p
convention to be downright archaic!) How about:

  (defun semicolon? (char) (if (char= #\; char) t nil))

[Yes, I know that you don't need the nil, but we're going for clarity
here!]

Anyway, I don't get why anyone would write a function for this since
it's trivial code. Probably we just did someone's homework. C'est la
vie.
From: Raffael Cavallaro
Subject: Re: is-semicolumns function
Date: 
Message-ID: <2006110514343016807-raffaelcavallaro@pasdespamsilvousplaitmaccom>
On 2006-11-05 12:55:22 -0500, ·········@gmail.com" <········@gmail.com> said:

> (defun semicolon? (char) (if (char= #\; char) t nil))

Heretic! Heretic! Cast the scheme-namer out! ;^)

In case some readers are not aware, the distinction between the two 
naming conventions, mumblep v. mumble? is one of the things that 
separates common lisp from scheme - common lisp uses mumblep where 
scheme would use mumble?
From: Bulent Murtezaoglu
Subject: Re: is-semicolumns function
Date: 
Message-ID: <87ac35eowi.fsf@p4.internal>
>>>>> "JS" == JShrager  <········@gmail.com> writes:
[...]
    JS>   (defun semicolon? (char) (if (char= #\; char) t nil))

    JS> [Yes, I know that you don't need the nil, but we're going for
    JS> clarity here!]

Um, actually you don't need the if:

(defun semicolonp (char) (char= #\; char))

Soneone must have said this before though.  I just wanted to point out 
'-p' convention has followers too.  A convention for its use:

http://www.cliki.net/Naming%20conventions  (towards the bottom)

I don't mind -? in scheme code, but it doesn't look proper in CL code.

cheers,

BM
From: ········@gmail.com
Subject: Re: is-semicolumns function
Date: 
Message-ID: <1162762740.244131.22130@e3g2000cwe.googlegroups.com>
> Um, actually you don't need the if:
>
> (defun semicolonp (char) (char= #\; char))

You must have missed the just previous two posts, although I realize
that that's ancient history in usenet time. :-)
From: Thomas A. Russ
Subject: Re: is-semicolumns function
Date: 
Message-ID: <ymiac34a4fw.fsf@sevak.isi.edu>
chico <············@colettapc.com> writes:

> ········@gmail.com ha scritto:
> >> Obviously it doesn't work because ; means beginning of comments...
> >> Does someone have some ideas?
> > Sure it does:
> 
> > <2>> (defun is-columns (c)
> 
> > (cond ((char-equal c #\;) t)))
> > :: IS-COLUMNS
> > <3>> (is-columns #\;)
> > :: T
> 
> Well.... I cover myself in shame, I didn't try the function because i
> saw on the editor that the rest of the line was commented.... only a
> visualization problem.

I assume this is because of some sort of syntax-coloring that your
editor provides?  I guess it needs a better Lisp syntax algorithm.

> I asked because I was quite sure that there some special combination of
> caracter to represent special caracter.

Well, that's what the #\ part of #\; is for.  It identifies what follows
as a character object, so the lisp reader doesn't treat it as a comment.

Also, this can be much more succinctly written as

  (defun is-semicolon (c)
    (char= c #\;))

at which point you may decide that you don't need to write a special
function for this, since the direct code is so short and easy to
understand.

As a general point, I often run into code (often in Java) where
programmers seem to be afraid to just return the value of boolean
expressions.  Coming from Lisp, this just seems really weird, since
returning boolean expression (or the value of really any expression) is
much more in style.  I always groan when I see something like:

   boolean isBigNumber(int n) {
     if (n > 1000) {
       return true;
     } else {
       return false;
     }
   }

insted of the much simpler:

   boolean isBigNumber(int n) {
     return (n > 1000);
   }


-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: Ken Tilton
Subject: Re: is-semicolumns function
Date: 
Message-ID: <8cQ2h.589$AQ6.490@newsfe11.lga>
chico wrote:
> Hi all,
> I'm building a function that returns T if the passed char is a semicolumns.
> 
> (defun is-columns (c)
> (cond ((char-equal c #\;) t)))

Why no space in front of the second line?

> 
> Obviously it doesn't work because ; means beginning of comments...

Nah, The #\ escapes it:

  (char-code #\;) -> 59

> Does someone have some ideas?

(code-char 59) -> #\;

kt

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Pascal Bourguignon
Subject: Re: is-semicolumns function
Date: 
Message-ID: <87wt6coytv.fsf@thalassa.informatimago.com>
Ken Tilton <·········@gmail.com> writes:

> chico wrote:
>> Hi all,
>> I'm building a function that returns T if the passed char is a semicolumns.
>> (defun is-columns (c)
>> (cond ((char-equal c #\;) t)))
>
> Why no space in front of the second line?
>
>> Obviously it doesn't work because ; means beginning of comments...
>
> Nah, The #\ escapes it:
>
>  (char-code #\;) -> 59
>
>> Does someone have some ideas?
>
> (code-char 59) -> #\;

Here, (char-code (character ";")) --> 94

Use:  (character ";") or #.(character ";")  
if you don't want to use the escape.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Kitty like plastic.
Confuses for litter box.
Don't leave tarp around.