Lisp中的照应条件的示例将是什么? [英] What would be an example of an anaphoric conditional in Lisp?

查看:81
本文介绍了Lisp中的照应条件的示例将是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Lisp中反指条件的示例将是什么?请也解释代码.

What would be an example of an anaphoric conditional in Lisp? Please explain the code as well.

推荐答案

一个例子是Common Lisp LOOP:

An example is the Common Lisp LOOP:

(loop for item in list
      when (general-predicate item)
      collect it)

变量IT具有测试表达式的值.这是ANSI Common Lisp LOOP工具的功能.

The variable IT has the value of the test expression. This is a feature of the ANSI Common Lisp LOOP facility.

示例:

(loop for s in '("sin" "Sin" "SIN")
      when (find-symbol s)
      collect it)

返回

 (SIN)

因为仅"SIN"是现有符号的名称,此处为符号SIN.在Common Lisp中,符号名称默认情况下内部具有大写名称.

because only "SIN" is a name for an existing symbol, here the symbol SIN. In Common Lisp symbol names have internally uppercase names by default.

这篇关于Lisp中的照应条件的示例将是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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