📜  Clojure-决策

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


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

Sr.No. Methods & Description
1 If Statement

In Clojure, the condition is an expression which evaluates it to be either true or false. ‘If’ the condition is true, then statement#1 will be executed, else statement#2 will be executed.

2 If/do Expression

The ‘if-do’ expression in Clojure is used to allow multiple expressions to be executed for each branch of the ‘if’ statement.

3 Nested If Statement

Multiple ‘if’ statements embedded inside each other.

4 Case Statement

Clojure offers the ‘case’ statement which is similar to the ‘switch’ statement available in the Java programming language.

5 Cond Statement

Clojure offers another evaluation statement called the ‘cond’ statement. This statement takes a set of test/expression pairs.