开发者

In Lisp how can I check stream to see if it's empty without modifying it?

How can I che开发者_如何学Gock if the stream is empty without modifying it? At the moment I'm using peek-char to see if there a character, but it appears to wait for the user to enter something if nothing new is in the stream. Also, I don't know how to compare to an eof character... #\Space clearly won't work. Help please?

    (loop while (equal (peek-char) '#\Space) 
        do (print 'testword))


You just need to read the manual:

LISTEN checks if there is input available.

PEEK-CHAR can either signal an error at eof or return an eof value. You can also tell it what eof value to return.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜