开发者

Console I/O in Common Lisp

开发者 https://www.devze.com 2023-01-27 21:48 出处:网络
In Common Lisp, I am writing a console application. I\'ve finished most of the code, but two critical pieces are still confusing me.

In Common Lisp, I am writing a console application. I've finished most of the code, but two critical pieces are still confusing me.

  1. How to read a key from the input and get the ascii code for it.

  2. How to display an ascii character, without special formatting or newline.

On the second, I've tried:

(print (code-char 69))

Which displays:

#\E

But I just want it to display a plain:

E

On the first,开发者_如何学C I've had no luck at all.

If it helps, I am running clisp on Linux and OS X. Thanks!


See read-char and write-char in the streams CLHS chapter. READ-CHAR reads a character. Portable Common Lisp does not have the capabilities to read 'keys', but it can read characters from a stream.

For getting the code of a character see char-code.


to get a plain "E", execute

(princ (code-char 69))
0

精彩评论

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

关注公众号