I have a program that is a simple reader. Reads the user input character by character, and then creates a list of values. Right now it only works with numbers, but i will add functionality for reading characters. Right now it will work, and just accept the numbers and create the list which is great, but It won't work for nested lists at all. I don't think it should be that difficult to modify it, but it is proving to be harder than I anticipated. <br clear="all">
<br>(define (read-list chr)<br> (define (read-list-helper list-so-far)<br> (let ((next-char (peek-char))<br> (this-char (read-char)))<br> (cond [(char-numeric? next-char)(read-list-helper (cons this-char list-so-far))]<br>
[(or (eq? next-char #\')<br> (eq? next-char #\))<br> (eq? next-char #\()<br> (eq? next-char #\space)) (read-list-helper list-so-far)]<br> [(reverse list-so-far)])))<br>
(read-list-helper '()))<br><br>The reading function passes it a character which I suppose it really doesn't have to, however I thought to accept the nested list that I would need to pass a list back into it when it read a "(". I had tried passing the list-so-far value to read-list, and modified the (read-list-helper '()) to be (read-list-helper (list chr)) which did work kind of for input of (3 (4 5)), but nothing else. Any ideas or suggestions?<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>