Code Comments
Programming Forum and web based access to our favorite programming groups.Reading from a text file... I wrote a program to find an occurence of a string in a text file, and I tested it on several text files, but Scheme has a problem reading the ' character as a symbol. Any suggestions? The program works great besides that... It took me AWHILE, but I finally got it... Now if I could just get the bugs out... Are there any other characters Scheme might not recognize as symbols that I should know about?
Post Follow-up to this messageaudibel writes: > Reading from a text file... > I wrote a program to find an occurence of a string in a text file, > and I tested it on several text files, but Scheme has a problem > reading the ' character as a symbol. Any suggestions? The program > works great besides that... It took me AWHILE, but I finally got > it... Now if I could just get the bugs out... Are there any other > characters Scheme might not recognize as symbols that I should know > about? You will have problems with all manner of lexical syntax if you read with READ. READ is a parser. Characters include "',;() that certainly occur in text, and also #`\ and probably [|]. Digits and and +-. put you into number syntax and will cause problems. Maybe you can preprocess the text so that problem cases are encoded safely before you read them into Scheme. Better may be to write your own reader and tokeniser; your implementation may provide at least read-line to read a line as a string - it isn't hard to write - and also tools to do things with strings. You can, actually, turn ' into a symbol by (string->symbol "'") but I suspect you would be better off working with strings.
Post Follow-up to this messageI didn't even think about numbers, the example texts I used both were small white lists of hyperlinks, so most of the data was in one continious string, thanks. My book uses read to read from a text file, so I thought that would be the procedure to use. I'll look for a read line procedurce, if not I assume I'll have to use a read-char to make my own read line, which shouldn't be too hard. One thing I noticed about my program and PLT Scheme in general that I didn't like. I had Windows Task Manager (Yes, Computer Gods forgive me, for right now I am using Windows) open and Plt Scheme is taking anywhere from 50 - 80 megs of RAM??? The program binary for this little text grep wannabe is sucking up about 7 megs of RAM??? Is that something I am doing wrong in my code, or do Scheme programs usually suck system resources like that? This isn't a huge file, we're talking probably less than 50 lines of code.
Post Follow-up to this message"audibel" <audibel@sbcglobal.net> writes: > One thing I noticed about my program and PLT Scheme in general that I > didn't like. I had Windows Task Manager (Yes, Computer Gods forgive me, > for right now I am using Windows) open and Plt Scheme is taking anywhere > from 50 - 80 megs of RAM??? The program binary for this little text grep > wannabe is sucking up about 7 megs of RAM??? Is that something I am doing > wrong in my code, or do Scheme programs usually suck system resources like > that? Are you saving it for something? 7 meg of physical RAM goes for about a buck (SO-DIMM PC2100 DDR). Virtual memory costs less.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.