Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Console I/O in Common Lisp

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, I've had no luck at all.

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

like image 528
crc Avatar asked Jan 22 '23 00:01

crc


1 Answers

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.

like image 119
Rainer Joswig Avatar answered Jan 23 '23 13:01

Rainer Joswig