Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Casting a character to a string in common lisp

Casting a character to a string in common lisp

Casting a character to a string in common lisp

I am very new to common lisp so sorry if this is a newbie question.  I am trying to write a function that take a stream read from a file as input and adds all the character that are not /s to a string.  So my input will look something like this:  
4//4 3//3 2//2 1//1
and here is the method I made:  
(defun READ-INT(String)
  (let ((Number  ""))
      (let((num-char ""))
      (setf num-char (read-char String)) ; ))))

        (if (equal num-char #\/) (return-from read-int Number)
          (setf Number (concatenate 'string Number num-char)))
        (print Number)
        (print num-char)
        ))) )
The String parameter is a stream that I read in form a file, I initialize Number and num-char to empty strings then setf num-char to be the first char read from the stream.  Then if the char is a / I return what I have so far and if not I add try and add the character to the Number string but it gives this error
"Error: value #\4 is not of the expected type SEQUENCE."
So I think my problem is that the character 4 is not a string so it can't perform the concatenate.  Is there an easy way to cast the char to a string?  I found something called char-to-string on an emacs lisp page but it does not seem to be in the Clozure cl implementation.  Is there something similar in Clozure?  Thanks.   

RE: Casting a character to a string in common lisp

Hi ender2012,

I don't understand good what you exactly want to do.
When your input is e.g. this


4//4 3//3 2//2 1//1
and you say, that it should add "all the character that are not /s to a string", then should be this your ouput ?


4/ 3/ 2/ 1/
Or something else?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close