📜  LISP-决策

📅  最后修改于: 2020-11-03 07:09:21             🧑  作者: Mango


决策结构要求程序员指定一个或多个要由程序评估或测试的条件,以及确定条件为真的情况下要执行的一条或多条语句,以及如果条件被确定为可选的其他执行语句确定为假。

以下是大多数编程语言中常见的典型决策结构的一般形式-

做决定

LISP提供以下类型的决策构造。单击以下链接以查看其详细信息。

Sr.No. Construct & Description
1 cond

This construct is used for used for checking multiple test-action clauses. It can be compared to the nested if statements in other programming languages.

2 if

The if construct has various forms. In simplest form it is followed by a test clause, a test action and some other consequent action(s). If the test clause evaluates to true, then the test action is executed otherwise, the consequent clause is evaluated.

3 when

In simplest form it is followed by a test clause, and a test action. If the test clause evaluates to true, then the test action is executed otherwise, the consequent clause is evaluated.

4 case

This construct implements multiple test-action clauses like the cond construct. However, it evaluates a key form and allows multiple action clauses based on the evaluation of that key form.