943,729 Members | Top Members by Rank

Ad:
Jun 12th, 2008
0

Dr scheme read text file help

Expand Post »
I am trying to make a program that will take a list of words from a .txt file and add the alphabet to the end of each word.

the code i have just makes it read and re-read the first line. since each list will be different i cant just do

(read-line)
(read-line)
(read-line)


etc....
because each list will have different amounts of lines


the way i want to have it read is to get the first line, add a,b,c,d etc... to the end then goto the next line.


This is my code i have to get from file
(define (adder path)
     (alpha-get "test.txt"))
  
(define (alpha)
0)
 
(define (alpha-get dir)
    (set! alpha 
      (list (with-input-from-file dir
               (lambda ()
                (list
                  (read-line))))))
     (begin
     (display alpha)
    (alpha-get "readsme.txt")))

im forgetting the add suffix for the moment as i know how to do that

can someone help me please. the procedure to get the files id alpha-get.


any help with higher order procedures that might do what i need would be great
Last edited by captainhair; Jun 12th, 2008 at 5:50 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
captainhair is offline Offline
5 posts
since Apr 2007
Jun 18th, 2008
0

Re: Dr scheme read text file help

I'm not competent enough in scheme to provide much help, but it might be easier to read in the whole file, split it into lines, add the alphabet, and then print it all back to the file.

On the other hand.
If you put "dir" outside of the recursion, it might work.

Hmm... I don't have time to show you the code I'm thinking at the moment... tonight!

Anyway, if you use a letrec inside of alpha-get, so you don't use dir as part of the recursive call, each read-line should get the next line in the file.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
cknapp is offline Offline
16 posts
since Feb 2008
Jun 19th, 2008
0

Re: Dr scheme read text file help

never mind i worked it out myself. thanks for the help though
Reputation Points: 10
Solved Threads: 0
Newbie Poster
captainhair is offline Offline
5 posts
since Apr 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Legacy and Other Languages Forum Timeline: Creating .EXE's in Smalltalk/Squeak
Next Thread in Legacy and Other Languages Forum Timeline: HELPPPPPPPP, Need to know about Windows XP and QuickBasic USB printer driver access





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC