开发者

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

开发者 https://www.devze.com 2023-03-02 00:15 出处:网络
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 not

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

精彩评论

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