As an example, I want have most of the functions for Plus, Minus already written.<br><br>Here is the code for it.<br><br>(define (plus num1 num2)<br>(+ num1 num2))<br><br>That is childs stuff... Here is where I am having the problem, and please keep in mind I am new to DrRacket...<br>
<br>If my program accepts input such as <br>(plus 13 5)<br><br>I need to parse it so that I know what it is asking for. If It is a left parent, then I need to move on, if it is a right parent, move on to the next character, once i get to the next character I can see it is an alphanumeric character, but then I need to somehow read the whole word, so that I can store that value in a variable so that I can read the next number. If the numbers are single digits, it is easy, because they are only one charater each and read-char works perfect, but I need something like a read-word, or read-number and I can't seem to figure out how to do it. <br>
<br>So really I need to know how do I read the words when there are characters present, and read the whole numbers when there is a number present.<br><br><div class="gmail_quote">On 9 November 2010 15:00, John Clements <span dir="ltr"><<a href="mailto:clements@brinckerhoff.org">clements@brinckerhoff.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im"><br>
On Nov 9, 2010, at 11:48 AM, Peter Breitsprecher wrote:<br>
<br>
> I am in the process of writing a simple scheme interpreter for a class I have. I am running into an issue with regards to parsing the input properly. I will try and explain what I want to do and tell me if I am way off base or not. I have a procedure set up to read the input from the user. Which is just a simple display read function. I want to pass that read value in, and then read it character by character. If it is a "(" then up a counter(to make sure there is an equal number of ")", if it is a number, i want to read the number and store it into a variable, and if it is an operator I want to pass the variables to the proper functions I have written to evaluate the input.<br>
><br>
> I'm really stuck at step 2... I can read the input, however I can't seem to pass that input to another function and then break it down character by character.. I thought read-char should do it, but it only seems to work if it is in the function to read the input.. and it doesn't seem to work if passed to another function..<br>
<br>
</div>I understand your big picture, but I have no idea what kinds of functions you're trying to write. Can you describe the function you're trying to write in one line, then specify what it takes and what it returns, and provide a few examples of what you expect it to produce on certain inputs?<br>
<br>
In the book "How To Design Programs", these are the first few steps of the "Design Recipe," and it sounds like they would help you clarify what it is you're trying to do.<br>
<br>
All the best,<br>
<font color="#888888"><br>
John Clements<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br><div>Kurt Breitsprecher</div>
<div>(807) 474-9601</div>
<div><a href="mailto:pkbreits@lakeheadu.ca" target="_blank">pkbreits@lakeheadu.ca</a></div><br>