Do conditional expressions produce a Boolean result?

Fundamentals of IDL Syntax

LIAM E. GUMLEY, in Practical IDL Programming, 2002

Ternary Operator

In the following example, an if statement is used to find the minimum of two scalars:

Do conditional expressions produce a Boolean result?

Do conditional expressions produce a Boolean result?

An alternative to this statement uses the ternary operator ?: to form a conditional expression:

Do conditional expressions produce a Boolean result?

A conditional expression has the general form

Do conditional expressions produce a Boolean result?

where expr1 is an expression that yields a true or false result. If the result is true, the value of the conditional expression is set to expr2. If the result is false, the value of the conditional expression is set to expr3. The type of the conditional expression is determined by the type of expr2 or expr3. Since the precedence of the ternary operator is very low (see Table 2.6), parentheses around expr1 are not required. However, parentheses are recommended to visually distinguish expr1 from the possible result values (expr2 and expr3).

Read full chapter

URL: https://www.sciencedirect.com/science/article/pii/B9781558607002500033

Discrete Time Process Algebra and the Semantics of SDL

J.A. Bergstra, ... Y.S. Usenko, in Handbook of Process Algebra, 2001

Syntax:

Do conditional expressions produce a Boolean result?

An operator application op (el,…,en) evaluates to the value yielded by applying the operation op to the current values of the expressions el,…, en.

A conditional expression if el then e2 else e3 fi evaluates to the current value of the expression e2 if the current (Boolean) value of the expression el is true, and the current value of the expression e3 otherwise.

A variable access v evaluates to the current value of the local variable v of the process evaluating the expression.

A view expression view (v, e) evaluates to the current value of the local variable v of the process with the current (pid) value of the expression e as its address.

An active expression active (s (el,…,en)) evaluates to the Boolean value true if the timer identified with the signal type s and the current values of the expressions el,…, en is currently active, and false otherwise.

The expression now evaluates to the current system time.

The expressions self, parent, offspring and sender evaluate to the pid values of the process evaluating the expression, the process by which it was created, the last process created by it, and the sender of the last signal consumed by it. Natural numbers are used as pid values. The pid value 0 is a special pid value that never refers to any existing process – in full SDL this pid value is denoted by null – and the pid value 1 is reserved for the environment. The expressions parent, offspring and sender evaluate to 0 in case there exists no parent, offspring and sender, respectively.

Read full chapter

URL: https://www.sciencedirect.com/science/article/pii/B9780444828309500369

Embedded SQL, CLI Dynamic SQL, and SQL/PSM

Joe Celko, in Joe Celko's SQL for Smarties (Fifth Edition), 2015

38.4.5 Conditional Statements

There are two forms of conditional execution statements, the IF and the CASE. The syntax for the simple IF statement is the same as other languages.

IF < conditional expression >

THEN < statement list >

[ELSE < statement list >] END IF;

If the conditional expression yields TRUE, the statement in the THEN clause is executed. If the conditional expression tests to FALSE or UNKNOWN, then the ELSE clause is executed.

One or more IF statements can be nested, one within the other, by using an ELSEIF clause in place of the ELSE clause in the IF statement containing another.

IF < conditional expression >

THEN < statement list >

ELSEIF < conditional expression >

THEN < statement list >

ELSE < statement list >

END IF;

Once the SQL statements to be executed have been selected, they execute in the same way as any ordinary list of SQL statements. This is important when creating handlers.

Examples:

IF a > 50 THEN

SET a = 50;

SET b = 1;

ELSE

SET b = 0;

END IF;

IF a > 50 THEN

SET a = 50;

SET b = 2;

ELSEIF a > 25

THEN SET b = 1;

ELSE SET b = 0;

END IF;

SQL/PSM has a CASE statement, which is not to be confused with the CASE expression in SQL. The simple CASE statement looks like the simple CASE expression with statement lists instead of scalar expressions in the THEN and ELSE clauses. Another difference is that it ends with END CASE, to keep the ADA-style statement terminators

A simple CASE works by evaluating equality between one value expression and one or more alternatives of a second value expression. For example:

BEGIN

DECLARE b INTEGER;

CASE b

WHEN 1 THEN UPDATE Foobar SET x = 1;

WHEN 2 THEN UPDATE Foobar SET x = 2;

WHEN 3 THEN UPDATE Foobar SET x = 3;

ELSE UPDATE Foobar SET x = 4;

END CASE;

END;

Like wise the searched CASE statement works the same way.

A searched CASE works by evaluating, for truth, a number of alternative search conditions. For example:

CASE

WHEN EXISTS (SELECT * FROM BILL)

THEN UPDATE Foobar SET x = 1;

WHEN a > 0 OR b = 1

THEN UPDATE Foobar SET x = a + b;

ELSE UPDATE Foobar SET x = -99;

END CASE;

A list of one or more SQL statements can follow the THEN clause for each of the conditional statements. Each alternative list of SQL statements in a CASE statement is treated in the same way, with respect to the behavior of exception handlers and so forth. They are not considered, in any sense, to be a single statement.

The conditional part of each WHEN clause is evaluated, working from the top of the CASE statement down. The SQL statements that are actually executed are those following the THEN clause of the first WHEN condition to evaluate to TRUE. If none of the WHEN conditions evaluate to TRUE, the SQL statements following the CASE statement ELSE clause are executed.

The presence of an ELSE clause in the CASE statement is optional and if it is not present (and none of the WHEN conditions evaluate to TRUE) an exception condition is raised to indicate that a WHEN or ELSE clause was not found for the CASE statement. If you do not want this exception, use an empty statement—ELSE BEGIN END.

Read full chapter

URL: https://www.sciencedirect.com/science/article/pii/B9780128007617000383

Logic and Cognition, Psychology of

R. Revlin, in International Encyclopedia of the Social & Behavioral Sciences, 2001

1.3 Conditional Reasoning

Conditional syllogisms have as their central statement, a conditional expression of the form If P is true, then Q is true. Although conditional syllogisms are logically equivalent to categorical syllogisms, they have a communicative property that makes them especially interesting to psychologists in studying how people reason with them. The external marker If allows for an incredible range for conjecture: the reasoner can interpret it to mean let's suppose that …, or someone believes that … (e.g., Paul believes that if P, then Q, even though he may be wrong), or to perform some action, there is a set of conditions that must be followed (e.g., If you're drinking alcohol, you must be the right age), and so forth. That is, conditional syllogisms reveal the very property that makes human inference so dynamic: an ability to consider truth at many levels. When adults are presented with conditional syllogisms that have an unambiguous conclusion to be drawn, they are rapid and accurate:

If P then Q If P then Q.
P is true not Q is true.
Therefore: Q Therefore not P.

These problems are called modus ponens and modus tolens, respectively. The former tends to be more accurately solved than the latter, but people demonstrate real skill in solving these problems without any special training. In cases where the conclusion is ambiguous, students take longer to reach a decision and tend to equivocate and generally draw an incorrect conclusion:

If P then Q If P then Q.
Not P Q.
Therefore: ? Therefore: ?

Just as with other forms of inference, interpretation of the relational terms is critical to accurate judgment. A common error among adults is to assume that a kind of unique causal structure holds when they hear If P then Q. That P somehow causes Q and that it uniquely does this. This typically goes by the name biconditional interpretation: If P is true then Q is true and if Q is true, so must P (Taplin 1971). You will notice that this is similar to the ‘converted interpretation’ on categorical syllogisms. It has been argued that there is a developmental sequence in the ability to solve conditional syllogisms which is linked to the child's interpretation of the conditionals. Very young children treat conditionals as conjunctions, slightly older children treat them as biconditionals, and adolescents and adults are able to treat them as one-way conditionals. Just as with categorical reasoning, conditional inference is sensitive to the content of the material reasoned about. This is particularly striking when people have to test conditional rules (Cox and Griggs 1983). When the rules and situations match a type or schema (e.g., a permission rule: If you meet the requirements, you can perform an action), reasoning can be sharply more accurate than if the conditional rule is arbitrary (Cheng and Holyoak 1989, Cosmides and Tooby 1997). The ease and ubiquity of this kind of reasoning suggests it may actually be a part of the human cognitive apparatus, part of our biological heritage that permits us to engage in effective social interactions.

Read full chapter

URL: https://www.sciencedirect.com/science/article/pii/B0080430767014844

JavaScript

William J. Buchanan BSc, CEng, PhD, in Software Development for Engineers, 1997

26.7 Conditional statements

Conditional statements allow a program to make decisions on the route through a program.

26.7.1 if … else

A decision is made with the if statement. It logically determines whether a conditional expression is TRUE or FALSE. For a TRUE, the program executes one block of code; a FALSE causes the execution of another (if any). The keyword else identifies the FALSE block. Braces are used to define the start and end of the block.

Relationship operators (>,<,>=,<=,==, ! =) yield a TRUE or FALSE from their operation. Logical statements (&&, | |, !) can then group these together to give the required functionality. If the operation is not a relationship, such as bitwise or an arithmetic operation, then any non-zero value is TRUE and a zero is FALSE.

The following is an example syntax of the if statement. If the statement block has only one statement the braces ({}) can be excluded.

Do conditional expressions produce a Boolean result?

The following is an example format with an else extension.

Do conditional expressions produce a Boolean result?

It is possible to nest if … else statements to give a required functionality. In the next example, statement block1 is executed if expression1 is TRUE. If it is FALSE then the program checks the next expression. If this is TRUE the program executes statement block2, else it checks the next expression, and so on. If all expressions are FALSE then the program executes the final else statement block, in this case, statement block 4:

Do conditional expressions produce a Boolean result?

Read full chapter

URL: https://www.sciencedirect.com/science/article/pii/B9780340700143500712

Interface Tier Design with IFML

Raul Sidnei Wazlawick, in Object-Oriented Analysis and Design for Information Systems, 2014

12.8.4 Connect, disconnect, and reconnect operations

The connect, disconnect, and reconnect operations have an association as a source of data. The connect and disconnect operations have two conditional expressions: one for the origin role and the other for the target role of the association. The reconnect operation may be understood as a combination of the former ones. It has three conditional expressions: one for the origin role, another for objects in the target role to be disconnected, and a third for objects in the target role to be connected to the source objects.

The connect, disconnect, and reconnect operations may add, remove, or replace links between sets of objects. If, for example, five objects satisfy the source conditional expression and three objects satisfy the target conditional expression, then a connect operation would create 15 links: each of the five origin objects will be linked to each of the three target objects.

The example in Figure 12.62 shows how a link between a book and a publisher may be created. First of all, the link is mandatory from the book to the publisher. Thus, it is not possible simply to get a list of books and a list of publishers and choose which ones should be linked. A link between a book and a publisher must be created as soon as the book is created. Furthermore, that link is immutable and cannot change later.

Do conditional expressions produce a Boolean result?

Figure 12.62. IFML model showing an interface in which books may be created and linked to publishers.

On the first page, Choose Publisher, there is a simple list of publishers. The user may choose one and be taken to Publisher Page. There, the publisher’s details and a list of books already linked to it are shown. Notice that Publisher Details has a key condition and a flow from Publishers List, and therefore, it shows the publisher selected in the list. The Publisher’s Books list has a data flow coming from Publisher Details and a role-based conditional expression so that only books that are linked to the publisher of Publisher Details are shown. Figure 12.63 shows the Publisher Page rendered after the publisher “Bantam” was selected from the list.

Do conditional expressions produce a Boolean result?

Figure 12.63. Rendering of the Publisher Page.

From the Publisher Page the user may navigate to the New Book Form by using a normal navigation flow between both pages, which is rendered as the New Book link. In this page the user may fill in the form with information about the new book, which will be automatically linked to the publisher presented in the Publisher Page. Initially the create operation creates the new instance of book. Its OK flow leads to a connect operation that is based on the association BookToPublisher. The flow that comes from the create operation has the new book key as a parameter binding; that key is used in the source conditional expression. The publisher is the target and it is obtained by a data flow coming from Publisher Details.

If the connect operation is successful, it returns focus to the Publisher Page, where the new book can be seen in the list of the current publisher’s books. If the create or connect operation fail then focus goes to a page with an error message.

However, the design shown in Figure 12.62 is not safe. If a book is created and the connect operation fails, that book would remain inconsistent regarding its definition. IFML allows a transaction to be defined as a group of operations. Figure 12.64 shows an operation group being defined to include both the create and connect operations. As the operation group may be defined as a transaction ([T]), either all of the operations inside the group succeed or the whole group fails. In that case a single KO flow from the group is followed.

Do conditional expressions produce a Boolean result?

Figure 12.64. A safer design for Figure 12.62 using an operation group.

Read full chapter

URL: https://www.sciencedirect.com/science/article/pii/B9780124186736000120

Structured Design Methodologies

Konrad Morgan, in Encyclopedia of Information Systems, 2003

IV.D.3.a. The “Repeat Until” Loop

Do conditional expressions produce a Boolean result?

This looping construct obeys the statements inside the keywords “Repeat” and “Until.” Each time the program reaches the “Until,” the Conditional_expression is evaluated, and if it is false the program goes back to the Repeat part of the code. However, if the Conditional_expression found at the end of the loop is found to be true, the program leaves the loop and continues to the next statement after the Until.

An example will probably be the best way of demonstrating this process. Assume that we are using pseudocode to express a situation where a lecturer continues to talk until the end of the lecture, which for convenience we can assume is 4:15 p.m. We could express this in the following way.

Do conditional expressions produce a Boolean result?

In this example the lecturer enters the classroom and immediately begins to talk, after each utterance he checks his watch to see if it is time for the lesson to end (4:15 PM). If it is not 4:15 PM the lecturer continues to talk, and this process repeats until the lecturer's watch displays the value 4:15 PM.

Read full chapter

URL: https://www.sciencedirect.com/science/article/pii/B0122272404001726

Volume 2

Sridhar Selvaraj, Rita C.R. Perlingeiro, in Encyclopedia of Tissue Engineering and Regenerative Medicine, 2019

Muscle Diseases

iPS cell-based regenerative medicine has been investigated for some types of muscular dystrophy. The therapeutic potential of myogenic progenitors derived from human iPS cells using conditional expression of PAX7 has been tested for DMD using mdx mice. Myogenic progenitors were transplanted directly into the tibialis anterior (TA) muscle of dystrophic mice, and 8 weeks later, evaluation was performed in transplanted and PBS-injected TA muscles. The presence of donor-derived fibers was confirmed by the presence of both human dystrophin and lamin A/C. Importantly, it was observed that transplanted cells were able to seed the satellite cell pool, as shown by the presence of donor-derived cells double positive for PAX7 and human lamin A/C under the basal lamina, suggesting that engrafted cells may promote long-term muscle regeneration. This is in accordance with the finding that donor-derived myofibers were detectable 11 months posttransplantation. Of therapeutic significance, muscle engraftment was accompanied by improvement in muscle function. More recently, gene corrected DMD iPS cell-muscle derivatives have been transplanted in mdx mice. Gene correction of DMD iPS cells was induced by CRISPR-CAS9 mediated deletion of exons 45–55, a strategy that could target about 60% of the DMD mutations, by rescuing expression of partially functional dystrophin protein. Gene corrected iPS cells were differentiated into myogenic progenitors and transplanted into the TA muscle of mdx mice. Expression of human dystrophin was found in some muscle fibers, indicating the potential for autologous cell therapy applications.

Gene editing has also been applied in LGMD2D iPS cells. Gene correction was achieved using a lentiviral vector expressing the sarcoglycan gene under a muscle-specific promoter. Gene corrected iPS cells were differentiated into mesoangioblasts and these transplanted in sarcoglycan-deficient mice. Engraftment analysis showed restoration of sarcoglycan protein expression. These studies show the potential of iPS cell-based regenerative medicine for the treatment of muscular dystrophies.

Read full chapter

URL: https://www.sciencedirect.com/science/article/pii/B9780128012383655046

Meta-analytic design patterns

Steven Simske, in Meta-Analytics, 2019

4.2.1 Identifying zones of interest

One useful technique for identifying zones of interest is the use of a conditional cumulative response curve. Fig. 4.2 introduces this useful tool. As with any conditional expression, the joint probability of an event of interest, A, and an event known or assumed to have occurred, B, is dependent on having the events refer to the same partition of the overall probability space. Given any set of samples large enough to make the creation of a cumulative response curve feasible, there is a diminishingly small chance of any two analytic approaches having the same ranked order of samples. Therefore, in order to illustrate how the individual approaches are affected by the samples, we need to “pin” the sample ordering based on the ranked order of just one of the approaches. The approach (classifier, regression algorithm, clustering algorithm, etc.) that is used to pin the sample ordering is termed the “anchoring analytic.” The manner in which to do this is illustrated by Fig. 4.2 and described next.

Do conditional expressions produce a Boolean result?

Fig. 4.2. Cumulative response curves for Classifier A (upper curve) and Classifier B (lower curve). The samples are chosen in the same order, based on the rankings for Classifier A. Thus, the curve for Classifier A is smoother than that for Classifier B, since the curve for Classifier B is actually a conditional cumulative response curve.

In Fig. 4.2, the cumulative response curve (hereafter “CRC”) for Classifier A is used as the anchoring analytic (upper curve), as its performance is better than that of Classifier B (data not shown). This is because the area under the CRC is equal to 0.8256 for Classifier A but only 0.8078 for Classifier B. In general, when selecting the anchoring analytic for a conditional cumulative response curve (hereafter “CCRC”), select the analytic with the highest area under the CRC. When the ordering of anchoring analytic A is used, we see the CCRC for Classifier B as the lower curve in Fig. 4.2. This curve has a much lower area than the area under the CRC for Classifier B when Classifier B’s sample ranking is used—it is 0.7512 instead of 0.8078. This means that there is a reduction in area under the curve of 0.8078 − 0.7512 = 0.0566 in CCRC when compared with the CRC. This is a large difference, but more importantly, it is an opportunity.

Looking once more at Fig. 4.2, we see that the curve for Classifier A is smoother than that for Classifier B, since the curve for Classifier B is a CCRC and thus has some “disjointedness” where its ranking order of the samples deviates meaningfully from that of Classifier A.

Fig. 4.3 makes the relationship between the CRC for Classifier A, the anchoring analytic, and the CCRC for Classifier B, the dependent analytic, more explicit. The lowest of the three curves in Fig. 4.3 represents the difference CRC(A)− CCRC(B). If the sample ranking behavior of Classifiers A and B were closely related, we would expect this curve, CRC(A)− CCRC(B), to be rather smooth and to generally not rise very much above two times the difference in overall classifier accuracy (since the domain and range for that matter are 1.0, no normalization of this value is necessary). Two smooth CRC curves will differ by a crescent moonlike sliver that is relatively well approximated by two triangles, and in such a case, the peak difference between two CRC curves will be approximately twice the mean difference, and thus twice the difference in area since the domain is (0, 1). For our example, this difference, CRC-Area(A) − CRC-Area(B), is 0.8256 − 0.8078 = 0.0178. In reality (data not shown), the peak difference between CRC(A) and CRC(B) occurs when x = 0.20 and is 0.694 − 0.643 = 0.051, which is still far less than the observed peak difference between CRC(A) and CCRC(B), which is 0.203 when x = 0.18.

Do conditional expressions produce a Boolean result?

Fig. 4.3. Cumulative response curves for Classifier A (CRC) and Classifier B (CCRC, with A’s CRC as the anchor analytic). The lowest curve is the difference between the two curves, CRC(A)− CCRC(B), which can be seen to have the greatest positive slope in the domain x =(0.07, 0.17) and the greatest negative slope in the domain x =(0.33, 0.58).

In Fig. 4.4, the first derivatives (on intervals of Δx = 0.01) of the two curves in Fig. 4.2 are plotted. The significance of these first derivatives is the topic of the next section.

Do conditional expressions produce a Boolean result?

Fig. 4.4. Plot of the first derivatives of the cumulative response curves for Classifiers A and B.

Read full chapter

URL: https://www.sciencedirect.com/science/article/pii/B9780128146231000046

Compiling Lisp

Peter Norvig, in Paradigms of Artificial Intelligence Programming, 1992

An if expression is compiled by compiling the predicate, then part, and else part, and by inserting appropriate branch instructions.

(defun comp-if (pred then else env)

 "Compile a conditional expression."

 (let (CL1 (gen-label))

 (L2 (gen-label)))

 (seq (comp pred env) (gen 'FJUMP L1)

 (comp then env) (gen 'JUMP L2)

 (list L1) (comp else env)

 (list L2))))

Read full chapter

URL: https://www.sciencedirect.com/science/article/pii/B9780080571157500236

Are conditional statements boolean?

The condition is a Boolean expression: an expression that evaluates to either true or false . Boolean values are another type of data type in programming languages, and they can only ever hold true or false.

How Boolean expressions are used in conditional statements?

if ( condition ) statement; if is a Java reserved word The condition must be a boolean expression. It must evaluate to either true or false. If the condition is true, the statement is executed.

What is the relationship between a boolean and a conditional?

A Boolean expression is a logical statement that evaluates to either TRUE or FALSE . Boolean expressions are used inside conditional statements to represent the question that is being asked. For example, 3 < 4 is a boolean expression that evaluates to TRUE .

Which statement generates a boolean value?

The equality operator, == , compares two values and produces a boolean value related to whether the two values are equal to one another. In the first statement, the two operands are equal, so the expression evaluates to True .