mit-scheme-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MIT-Scheme-devel] Re ading files in mit-scheme


From: Joe Marshall
Subject: Re: [MIT-Scheme-devel] Re ading files in mit-scheme
Date: Fri, 20 Jan 2012 15:07:00 -0800

Start with this:
(with-input-from-file "numbers.txt"
  (lambda ()
    (do ((thing (read) (read))
         (things '() (cons thing things)))
        ((eof-object? thing) things))))

On Thu, Jan 19, 2012 at 3:44 PM, Broseph
<address@hidden> wrote:
>
> Hello, I am an undergrad math student at Whittier college, and I have been
> trying to figure out how to read lines from a text file into a list of
> characters in scheme. I plan on using a list of prime numbers output from a
> python script i wrote, but i am having trouble getting the text from the
> file into a list. Could someone show me how this could be done? The file I
> am using has each prime number on a new line like this:
> 2
> 3
> 5
> 7
> 11
> 13
> etc.
> I want to put it into a list like this:
> ((#\2) (#\3) (#\5) (#\7) (#\1 #\1) (#\1 #\3))
> or
> ("2" "3" "5" "7" "11" "13")
> I am thinking this would be the easiest way to get the information into a
> list, since i have written functions for turning lists of characters or
> strings into an integer.
> In the end I want to output the numbers into a list:
> (2 3 5 7 11 13)
> --
> View this message in context: 
> http://old.nabble.com/Reading-files-in-mit-scheme-tp33171455p33171455.html
> Sent from the Gnu - MIT Scheme - Dev mailing list archive at Nabble.com.
>
>
> _______________________________________________
> MIT-Scheme-devel mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/mit-scheme-devel



-- 
~jrm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]