防止在LISP中输出终端 [英] prevent terminal output in LISP

查看:68
本文介绍了防止在LISP中输出终端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行一个函数,但不希望它在终端中输出结果.例如,(set 'A 'B)通常在控制台中返回B,如下所示:

I want to run a function but not have it output the result in the terminal. For example, (set 'A 'B) normally returns B in the console like the following:

 >>> (set 'A 'B)
 B
 >>> A
 B

我不希望它返回任何东西;我仍然希望函数默默地执行它应该做的事情:

I don't want it to return anything; I still want the function to do what it's supposed to, just silently:

 >>> (set 'A 'B)
 >>> A
 B

推荐答案

它并不完美,但是您可以在表达式的末尾使用(值)来抑制输出.您会得到一个空白行.

It's not perfect, but you can use (values) at the end of your expression to suppress output. You get a blank line instead.

常见的Lisp:

(progn (set 'A 'B) (values))

我不确定Scheme中的等效项.

I'm not sure of the equivalent in Scheme.

一个Lisp REPL总是打印一些返回值.如果您确实不想输出,则可以在终端中将代码作为脚本运行.

A lisp REPL always prints some return value. If you really didn't want output, you could run your code as a script in the terminal.

示例:

#!/path/to/interpreter
(set 'A 'B)
[rest of program]

这篇关于防止在LISP中输出终端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆