Line breaks in the input file should be ignored. In the output file, arrange for each integer to be printed on a line by itself.
(define copy-file
(lambda (source-file-name target-file-name)
(let ((source (open-input-file source-file-name))
(target (open-output-file target-file-name)))
(let loop ((ch (read-char source)))
(if (eof-object? ch)
(begin
(close-input-port source)
(close-output-port target))
(begin
(write-char ch target)
(loop (read-char source))))))))
Modify this procedure so that every lower-case letter that is read in is
converted to upper case before being written to the output file.
tally-char that takes two
arguments, the name of an input file and a character, and returns a tally
of the number of occurrences of that character in the specified file.
(tally-char "/home/walker/153/labs/data.1" #\5) ===> 4 (tally-char "/home/walker/153/labs/data.2" #\0) ===> 7 (tally-char "/home/walker/153/labs/data.2" #\newline) ===> 2
102.7 81.2 76.18 91.8 -36.4 76.4 18.53 80.3Write a procedure
process-file that has a file name as argument
and, for that file, finds the minimum of the first numbers in each line
(102.7, 76.18, -36.4, 18.53 in the example) and the average of the second
numbers (81.2, 91.8, 76.4, 80.3 in the example). Thus, the procedure call
(process-file "/home/walker/153/labs/data.3")should return (-36.4 82.425).
In developing your procedure for a general file, you may assume that the file is not empty.
generate-data, which takes a file name and number
n as arguments and which writes n random integers
between 1 and 10 (inclusive) to that file. On the file, each number should
be printed on a separate line .
This document is available on the World Wide Web as
http://www.math.grin.edu/~walker/courses/153/lab-file-examples.html