|
SketchyLISP Reference |
Copyright (C) 2007 Nils M Holm |
| <<[quotient] | [Index] | [remainder]>> |
Conformance: SketchyLISP Extension
Purpose: Read a newline-terminated sequence of characters. Return a string containing the characters read.
Implementation:
(define (read-line)
(letrec
((collect-chars
(lambda (c s)
(cond ((or (eof-object? c) (char=? c #\newline))
(apply string (reverse s)))
(else (collect-chars (read-char) (cons c s))))))
(first-char
(read-char)))
(cond ((eof-object? first-char) first-char)
(else (collect-chars first-char '())))))
Example:
(read-line) hello world => " hello world "
| <<[quotient] | [Index] | [remainder]>> |