Ok, here is the exact assignment.
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; line-height: normal;"><b style=""><u><span style="font-size: 14pt; font-family: "Times New Roman","serif";" lang="EN-CA"><br></span></u></b></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; line-height: normal;"><b style=""><u><span style="font-size: 14pt; font-family: "Times New Roman","serif";" lang="EN-CA">Tiny Scheme Details</span></u></b><b style=""><span style="font-size: 14pt; font-family: "Times New Roman","serif";" lang="EN-CA">:</span></b><span style="font-size: 12pt; font-family: "Times New Roman","serif";" lang="EN-CA"> The Scheme or LISP
that you are going to implement should include the following primitives:</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-align: justify; line-height: normal;"><b style=""><span style="font-size: 12pt; font-family: "Times New Roman","serif";" lang="EN-CA">T,
NIL, CAR, CDR, CONS, ATOM, EQ, NULL, INT,</span></b></p>
<p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-align: justify; line-height: normal;"><b style=""><span style="font-size: 12pt; font-family: "Times New Roman","serif";" lang="EN-CA">PLUS,
MINUS, TIMES, LESS, GREATER COND, QUOTE, DEFINE.</span></b></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; line-height: normal;"><span style="font-size: 12pt; font-family: "Times New Roman","serif";" lang="EN-CA">T and
NIL represent true and false. In general atoms may be identifiers or integers.
An identifier will start with a letter of the alphabet, and maybe followed by
one or more letters or digits; only uppercase letters will be used. No
underscores or other characters are allowed in identifiers. Integers may be
signed or unsigned,</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; line-height: normal;"><span style="font-size: 12pt; font-family: "Times New Roman","serif";" lang="EN-CA">i.e.,
25, +25, −25 are all legal.</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; line-height: normal;"><span style="font-size: 12pt; font-family: "Times New Roman","serif";" lang="EN-CA"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; line-height: normal;"><span style="font-size: 12pt; font-family: "Times New Roman","serif";" lang="EN-CA">CAR,
CDR, CONS are the standard Scheme primitive functions. ATOM returns T if its
argument is atomic, and returns NIL otherwise. INT returns T if its argument is
an atom that is a number. EQ works only on atomic arguments; it returns T if
its two atomic arguments are the same [or equal, for numbers] and NIL otherwise.
NULL returns T if its argument is NIL and NIL otherwise (non-atomic arguments
should be acceptable to NULL).</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; line-height: normal;"><span style="font-size: 12pt; font-family: "Times New Roman","serif";" lang="EN-CA">PLUS,
MINUS etc., take two numbers [integers] as their arguments and return the
result [an integer]. LESS and GREATER allow you to compare two integers and
return T if the first is less or greater than the second respectively.</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; line-height: normal;"><span style="font-size: 12pt; font-family: "Times New Roman","serif";" lang="EN-CA"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; line-height: normal;"><span style="font-size: 12pt; font-family: "Times New Roman","serif";" lang="EN-CA">COND
and QUOTE are the standard Scheme forms. DEFINE allows the user to define a new
function and use it later. A function definition looks like</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; line-height: normal;"><span style="font-size: 12pt; font-family: "Times New Roman","serif";" lang="EN-CA">(define
(f x) fb )</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; line-height: normal;"><span style="font-size: 12pt; font-family: "Times New Roman","serif";" lang="EN-CA"><span style=""> </span></span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; line-height: normal;"><span style="font-size: 12pt; font-family: "Times New Roman","serif";" lang="EN-CA">where
f is the function being defined; its formal parameter(s) is named x; and its
body is the Scheme expression fb. When this is “evaluated”, it should add a
pair (f . ((X Y) . fb)) to the d-list [the list of definitions that your
interpreter should maintain internally; actually, how you store function
definitions on the d-list is up to you; the above is only one possibility]. The
features of Tiny Scheme that have not been included are: LAMBDA, LABEL. These
are not needed because Define is sufficient for defining new functions.</span></p>
<br>I thought it would be easier to post it all instead of trying to explain it.<br><br><div class="gmail_quote">On 9 November 2010 15:37, 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 12:32 PM, Peter Breitsprecher wrote:<br>
<br>
> Ok, here is the code I have written so far for the function I am having trouble with...<br>
><br>
> (define (rep-loop)<br>
> (newline)<br>
> (display "repl>")<br>
> (read-token))<br>
<br>
</div>I'm going to ignore rep-loop.<br>
<div class="im"><br>
><br>
> (define (read-token)<br>
> (let ((expr (read-char)))<br>
> ((cond [(char-whitespace? expr) (read-token1)]<br>
> [(eq? expr #\() (read-token2)]<br>
> [(eq? expr #\)) (read-token3)]<br>
> [(char-alphabetic? expr) (read-token4)]<br>
> [(char-numeric? expr) (read-token5)]<br>
> [else (display "Exiting Loop")]))))<br>
<br>
</div>Okay! we've got a name: read-token.<br>
<br>
The way it's written, it's going to be very hard to test. This is because it operates on typed-in input.<br>
<br>
This program would be much easier to develop if you could write a function that accepts strings as input. Can we break the problem up this way?<br>
<font color="#888888"><br>
John Clements<br>
</font><div><div></div><div class="h5"><br>
<br>
> The cond calls other functions I have written just so I could see it if was reading the output letter by letter... Now I need to make read-token read the whole word if it sees a character and the entire number if it sees a number.<br>
><br>
> Is that getting closer?<br>
><br>
> On 9 November 2010 15:28, John Clements <<a href="mailto:clements@brinckerhoff.org">clements@brinckerhoff.org</a>> wrote:<br>
><br>
> On Nov 9, 2010, at 12:27 PM, Peter Breitsprecher wrote:<br>
><br>
> > I'd lie but no.. I was just trying to clarify what I was looking for. I gave a the code for one of the functions I had written, and then an example of the input the user is giving below, and then tried to describe in more detail what I needed help with...<br>
><br>
> Well, I'm glad you're not lying :).<br>
><br>
> Can you start by picking a name for the function that you're trying to write?<br>
><br>
> John Clements<br>
><br>
><br>
> > On 9 November 2010 15:23, Shriram Krishnamurthi <<a href="mailto:sk@cs.brown.edu">sk@cs.brown.edu</a>> wrote:<br>
> > Hi,<br>
> ><br>
> > That would not be considered an "example" for at least two reasons. Do you see why?<br>
> ><br>
> ><br>
> >> On Nov 9, 2010 12:17 PM, "Peter Breitsprecher" <<a href="mailto:pkbreits@lakeheadu.ca">pkbreits@lakeheadu.ca</a>> wrote:<br>
> >><br>
> >> 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>
> >><br>
> >><br>
> >> On 9 November 2010 15:00, John Clements <<a href="mailto:clements@brinckerhoff.org">clements@brinckerhoff.org</a>> wrote:<br>
> >> ><br>
> >> ><br>
> >> > On Nov 9, 2010, a...<br>
> >><br>
> >> --<br>
> >> Kurt Breitsprecher<br>
> >> (807) 474-9601<br>
> >> <a href="mailto:pkbreits@lakeheadu.ca">pkbreits@lakeheadu.ca</a><br>
> >><br>
> >><br>
> >> _________________________________________________<br>
> >> For list-related administrative tasks:<br>
> >> <a href="http://lists.racket-lang.org/listinfo/users" target="_blank">http://lists.racket-lang.org/listinfo/users</a><br>
> ><br>
> ><br>
> ><br>
> > --<br>
> > Kurt Breitsprecher<br>
> > (807) 474-9601<br>
> > <a href="mailto:pkbreits@lakeheadu.ca">pkbreits@lakeheadu.ca</a><br>
> ><br>
><br>
><br>
><br>
><br>
> --<br>
> Kurt Breitsprecher<br>
> (807) 474-9601<br>
> <a href="mailto:pkbreits@lakeheadu.ca">pkbreits@lakeheadu.ca</a><br>
><br>
<br>
</div></div></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>