Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How to characterp?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  14 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Divya  
View profile  
 More options Nov 4 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: "Divya" <ra...@frontiernet.net>
Date: 1999/11/04
Subject: How to characterp?
Show me the light!

If I try:
(characterp #\a) then I get T

How do I do the same for:

(setq temp '(a b c d))
(characterp (car temp)) gives me NIL.

How can I check if the car or my list is a character or not?

Thanks in advance.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Divya  
View profile  
 More options Nov 4 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: "Divya" <ra...@frontiernet.net>
Date: 1999/11/04
Subject: Re: How to characterp?
Sorry.  Maybe I should have been more clear.

Suppose the input to my function is a list.

I need to know if the car of this list is a character.  How can I check
this?

(defun my-func (list)
  (cond
    ((characterp (car list)) (do-something))
..........

)

But this check for "characterp" gives me false.

Thanks again.

Divya <ra...@frontiernet.net> wrote in message

news:7vtie4$15lg$1@node17.cwnet.frontiernet.net...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jim Driese  
View profile  
 More options Nov 4 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Jim Driese <jdri...@seanet.com>
Date: 1999/11/04
Subject: Re: How to characterp?
Characters and symbols are two different data types.  In this case, #\a is
a character and a is a symbol.  It appears that what you are really asking
is:  How can I check if the car of my list is a symbol whose print name is
a string of length 1?  This is one way to do it:

(defun my-characterp (sym)
  (equal 1 (length (symbol-name sym))))

which gives (under CMU Common Lisp):

* (my-characterp 'abc)

NIL
* (my-characterp 'a)

T
*  (my-characterp (car '(a b c)))

T
* (my-characterp (car '(abc b c)))

NIL
*

my-characterp would have to be modified to handle lists (i.e.
(mycharacterp '(a b c)) won't work).  Using a function such as
my-characterp is a bad idea anyway;  I recommend instead that you
familiarize yourself with the various Lisp data types (e.g. characters,
strings, symbols, etc.) and then determine which data type is best suited
for the problem at hand.

Regards,

Jim Driese


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
R. Matthew Emerson  
View profile  
 More options Nov 5 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: r...@nightfly.apk.net (R. Matthew Emerson)
Date: 1999/11/05
Subject: Re: How to characterp?

"Divya" <ra...@frontiernet.net> writes:
> Show me the light!

*fwap* (hits divya on the head with a lamp)

> If I try:
> (characterp #\a) then I get T

> How do I do the same for:

> (setq temp '(a b c d))
> (characterp (car temp)) gives me NIL.

> How can I check if the car or my list is a character or not?

You just did.

(a b c d) is a list of SYMBOLS.

(#\a #\b #\c #\d) is a list of CHARACTERS.

-matt


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Nov 5 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 1999/11/05
Subject: Re: How to characterp?
* Divya <ra...@frontiernet.net>
| Show me the light!

* R. Matthew Emerson
| *fwap* (hits divya on the head with a lamp)

  hmmm...  "lampda -- the ultimate source of light"

#:Erik, who fears he's about to be hit, too :)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jong-won Choi  
View profile  
 More options Nov 5 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Jong-won Choi <li...@yahoo.com>
Date: 1999/11/05
Subject: Re: How to characterp?
I read your recent message too. But I thought your recent message
neither has the clue.

characterp will return a true(T) or false(NIL) value.

In your example, a in '(a b c d) is not a character! It's called
"Symbol" so characterp
returns nil.

If you try your example with '(#\a #\b #\c #\d) you will get true when
you call characterp
with the list.

- jwc


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Bradshaw  
View profile  
 More options Nov 5 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@tfeb.org>
Date: 1999/11/05
Subject: Re: How to characterp?

* Divya  wrote:
> Show me the light!
> If I try:
> (characterp #\a) then I get T
> How do I do the same for:
> (setq temp '(a b c d))
> (characterp (car temp)) gives me NIL.
> How can I check if the car or my list is a character or not?

Like that.  It's not a character, it's a symbol!

        (characterp (car '(#\a #\b))) -> T

--tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Nov 5 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 1999/11/05
Subject: Re: How to characterp?
* "Divya" <ra...@frontiernet.net>
| I need to know if the car of this list is a character.  How can I check
| this?

  with CHARACTERP or (TYPEP <whatever> 'CHARACTER).

| But this check for "characterp" gives me false.

  then you don't have a character.  how hard can this be to understand?

  why don't you ask your real question, which ought to be very close to
  "what are characters in Common Lisp?"

#:Erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shin  
View profile  
 More options Nov 5 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: f...@retemail.es (Shin)
Date: 1999/11/05
Subject: Re: How to characterp?

On Thu, 4 Nov 1999 23:18:21 -0500, "Divya" <ra...@frontiernet.net> wrote:

: I need to know if the car of this list is a character.  How can I check
: this?
:
: (defun my-func (list)
:   (cond
:     ((characterp (car list)) (do-something))

That function actually does what you _say_ you want it to do. That is,
if LIST is '(#\c) then

   (characterp (car list))

will return T.

Be sure you understand the difference between a character and a symbol
in Lisp parlance. If you want your test to give T when LIST is '(c),
then you are not looking for characters:

   (characterp #\c) => T
   (characterp 'c) => NIL
   (symbolp #\c) => NIL
   (symbolp 'c) => T

   (setq x #\c) => #\c
   (characterp x) => T
   (symbolp x) => NIL

   (setq y 'c) => C
   (characterp y) => NIL
   (symbolp y) => T

But take into account that:

   (symbolp 'i-am-a-symbol) => T

Also, a hint on style: if the flow depends on a unique predicate as in
your code, WHEN is the natural choice.

-- Shin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Divya  
View profile  
 More options Nov 5 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: "Divya" <ravi_di...@hotmail.com>
Date: 1999/11/05
Subject: Re: How to characterp?
Thank you all for your answers.

I received some critique from some smart-asses too.  I don't think
I am doing bad for a 2 day old LISP programmer and I will ignore
this critique from, probably LISP programmers of 40 years, for whom
the basic concepts are second nature.

Divya

Divya <ra...@frontiernet.net> wrote in message

news:7vtlom$118c$1@node17.cwnet.frontiernet.net...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Janos Blazi  
View profile  
 More options Nov 5 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: "Janos Blazi" <jbl...@netsurf.de>
Date: 1999/11/05
Subject: Re: How to characterp?
Hey Eric!

I am getting jelaous now! Please shoot at me! AT ME! You do need anybody
else when you have ME!

But to be serious: It is probably possible to alter the READER so that I can
define, what a "charcter" means. Hm?

Erik Naggum <e...@naggum.no> schrieb in im Newsbeitrag:
3150797830083...@naggum.no...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Nov 6 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 1999/11/06
Subject: Re: How to characterp?
* Janos Blazi
| Hey Eric!

  sigh.  <capitoline-7vo0b2/INN-2.2.1/accr...@broadway.news.is-europe.net>,
  posted on 1999-11-03 01:40:55+01, contained your promise to _end_ your
  particular line of lunatic ravings, and I answered your questions in the
  spirit of that promise.  you promised, and I quote your very words:

| But all right.  This is my last response to you.  You may response once
| and I shall read your response and I shall not answer any more.  So
| please do not talk to me again (bur for your last response).

  I am not particularly surprised that you can't even keep simple promises,
  but can you AT THE VERY LEAST PLEASE SHUT UP?

#:Erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Janos Blazi  
View profile  
 More options Nov 6 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: "Janos Blazi" <jbl...@netsurf.de>
Date: 1999/11/06
Subject: Re: How to characterp?
I am very sorry but I think that you answered my posting on Russian mental
power AFTER our "final" messages. And my posting about Russian mental power
had really nothing to with you and was not in any way offending you.

So it was you who started again. But I did not mind. I admit I was angry of
you but I am not angry any more. I have forgiven you, dear Eric.

J.B.

Erik Naggum <e...@naggum.no> schrieb in im Newsbeitrag:
3150883876078...@naggum.no...

> * Janos Blazi
> | Hey Eric!

>   sigh.

<capitoline-7vo0b2/INN-2.2.1/accr...@broadway.news.is-europe.net>,


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Hanley  
View profile  
 More options Nov 8 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: David Hanley <d...@ncgr.org>
Date: 1999/11/08
Subject: Re: How to characterp?

Divya wrote:
> Thank you all for your answers.

> I received some critique from some smart-asses too.  I don't think
> I am doing bad for a 2 day old LISP programmer and I will ignore
> this critique from, probably LISP programmers of 40 years, for whom
> the basic concepts are second nature.

No biggie.  Symbols are not the most intutive thing for someone
moving from other computer languages.  You're doing fine.

dave


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »