我会坦率地说:这是家庭作业。以下代码定义了一个函数countup
,称为:
(countup "file1")
循环似乎无限期地运行。为什么,我该如何解决这个问题?
(define stats
(lambda (srcf)
(begin
(define in (open-input-file srcf))
(let loop (
(l 0)
(w 0)
(c 0)
(char (read-char in)))
(case char
((#\newline)
(loop (+ l 1) w(+ c 1) (read-char in)))
((#\space #\tab)
(loop l (+ w 1) (+ c 1) (read-char in)))
(else (loop l w (+ c 1) (read-char in))))
)
(close-input-port in)
(display l)
(display " ")
(display w)
(display " ")
(display c)
(newline)
'()))
)
;; srcf = source text file
(define countup
(lambda (srcf lstf)
(stats srcf)
)
)