저는 Scheme에 단어 계산 프로그램을 만들려고합니다. 내 라인, 단어 및 문자를 계산할 알고리즘을 찾았지만, 프로그램을 실행하기 시작하면 "The object # \ 1 is not applicable."이라고 알려줍니다. "1"은 내가 읽고있는 파일의 첫 번째 문자이며 "else"에 속해야합니다. 내가 보는 모든 것은 내 주장과 일치하기 때문에 나는 올바르게하고 있다고 생각하지만 분명히 어딘가에서 엉망이된다. 도와 줘서 고마워!제도 케이스 오류
(define files
(lambda (reading n)
(begin
(define in (open-input-file reading))
(let loop ((lines 0)
(words 0)
(chars 0)
(port (read-char in)))
(case (port)
((#\newline)
(loop (+ lines 1) words (+ chars 1) (read-char in)))
((#\space #\tab)
(loop lines (+ words 1) (+ chars 1) (read-char in)))
(else (loop lines words (+ chars 1) (read-char in)))))
(close-input-port in)
(display lines)
(display " ")
(display words)
(display " ")
(display chars)
(newline)
(display "Top ")
(display n)
(display " word(s):")
(newline)
'())))
[동료 사용자가 삭제 된 질문으로 인해 혼란에 빠졌습니다] (http://meta.stackexchange.com/questions/129578/) question-deleted-while-writing-answer). – sarnold