Clojure – Decision Making

clojure decision making

Clojure Decision-making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.

Sr.No.Methods & Description
1If 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.
2If/do Expression
The ‘if-do’ expression in Clojure is used to allow multiple expressions to be executed for each branch of the ‘if’ statement.
3Nested If Statement
Multiple ‘if’ statements embedded inside each other.
4Case Statement
Clojure offers the ‘case’ statement which is similar to the ‘switch’ statement available in the Java programming language.
5Cond Statement
Clojure offers another evaluation statement called the ‘cond’ statement. This statement takes a set of test/expression pairs.

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply