[plt-scheme] Character problem
I will need to say:
((char->symbol(string-ref string counter)) (string->symbol (string c)))
Or what do you mean by the function definitions? Thanks.
-Todd
-----Original Message-----
From: Robby Findler [mailto:robby at cs.uchicago.edu]
Sent: Tuesday, May 31, 2005 2:46 PM
To: Todd Dobmeyer
Subject: RE: [plt-scheme] Character problem
You need the function definitions I supplied below, too. ...
Robby
At Tue, 31 May 2005 14:43:17 -0400, "Todd Dobmeyer" wrote:
> I am trying to convert a character to a symbol using char->symbol with
this
> line:
>
> (char->symbol(string-ref string counter))
>
> This line is being sent as a argument to a function. But it says
> char->symbol is an undefined identifier. I am trying to grab a character
out
> of the string and turn it into a symbol. Thanks!
>
> -Todd
>
> -----Original Message-----
> From: plt-scheme-admin at list.cs.brown.edu
> [mailto:plt-scheme-admin at list.cs.brown.edu] On Behalf Of Robby Findler
> Sent: Tuesday, May 31, 2005 10:07 AM
> To: Robby Findler
> Cc: Todd Dobmeyer; plt-scheme at list.cs.brown.edu
> Subject: Re: [plt-scheme] Character problem
>
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> Oh, no. Sorry. That's what you want for `+' and other operators. For
> one-digit numbers, you'll want
>
> (define (char->number c) (string->number (string c)))
>
> for multi digit numbers, perhaps as a list of characters, you'll want:
>
> ;; chars->number : (listof char) -> number or false
> ;; returns #f when the chars don't form a valid number
> (define (chars->number cs) (string->number (apply string cs)))
>
> hth,
> Robby
>
> At Tue, 31 May 2005 08:59:55 -0500, Robby Findler wrote:
> > For list-related administrative tasks:
> > http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> >
> > Probably you want to call this function
> >
> > (define (char->symbol c) (string->symbol (string c)))
> >
> > on each element of your list.
> >
> > Robby
> >
> > At Tue, 31 May 2005 09:52:53 -0400, Todd Dobmeyer wrote:
> > > For list-related administrative tasks:
> > > http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> > >
> > > I am new to using Scheme. I am working on a Scheme project for a class
> > > at Wright State University. We have to read in RPN (reverse polish
> > > notation) expressions from a text file, convert this RPN string to a
> > > list, and then manipulate the list to work with (eval) to find the
> > > answer. I have everything working except for one part. That is when I
> > > am trying to convert the string to a list. I can use the string-ref
> > > with a counter in a loop to add each non-space character to the list
> > > because we are guaranteed to have numbers or operators only. My
> > > problem is that string-ref returns a character as #\5, which is the
> > > way to define a character. But eval cannot work on individual
> > > characters if you have a list of them. It needs the list to be '(+ 5
> > > 3) and not '(#\+ #\5 #\3) if I understand this correctly. Is there a
> > > simple way to truncate the #\ off each item? Thanks for any help you
> > > have!
> > >
> > > Todd Dobmeyer