我正在用 XLISP 编写一个程序,它要求我询问用户输入。我使用过 C 语言,它相当简单 bt 我是 LISP 的新手,尤其是 XLISP,这使得为它搜索正确的东西有点困难。我想用 XLISP 写的东西是这样的:
scanf("Enter your position: %d %d\n",pos1,pos2);
我如何在 XLISP 中编写它?
最佳答案
最基本的是带有程序 block (指令列表)的函数 enter-position
,例如progn :
(defun enter-position ()
(progn
(format t "Enter your position:")
(let pos1 (read))
(let pos2 (read))))
(输入可能需要通过辅助功能进行清理,但这是故事的另一部分)
pos1 和 pos2 这两个变量将具有“词法作用域”,因此它们在 enter-position
的作用域之外是不可见的。
关于lisp - 如何在 XLISP 中询问用户输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13444693/