[plt-scheme] Character problem

From: Todd Dobmeyer (dobmeyer.2 at wright.edu)
Date: Tue May 31 09:52:53 EDT 2005

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



Posted on the users mailing list.