On Tue, Nov 16, 2010 at 4:58 AM, Peter Breitsprecher <pkbre...@lakeheadu.ca>wrote:
> I know I am missing something small, but I made that change, and it is > terminating too soon, and not quite working correctly. The nested list > works fine, but the outer list isn't correct. > Example. > I give it input of '(3 (4 5) 6)) > and it returns > (((4 5) 3)) > > Which means it is terminating too soon, and it is reversing the inner list > properly, but not the outer list after it completes that inner recursion. Yes - as stated previously, you'll need to pass in the results from (cons (read-list-helper '()) list-so-far) back to the helper in order not to terminate early, and you should also check for the end of the file as well. Cheers, yc > > On 15 November 2010 21:13, YC <yinso.c...@gmail.com> wrote: > >> >> Correct - that's the idea for reading in a nested list, unless you were >> trying to flatten the list as you read them. >> >> The (cons (read-list-helper '() list-so-far) should also be passed again >> to your helper proc, or it terminates prematurely. >> >> You might also want to add a test to see if you are at the end of the the >> port, via eof-object?. >> >> Also - your chr is not used in your proc. If that's the input-port you >> will want to pass it to peek-char and read-char, otherwise they are read >> from current-input-port. >> >> Let's add back the mailing list if you have additional questions, so >> others might chime in. >> >> HTH. Cheers, >> yc >> >> > > >
_________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users