Answer the question
In order to leave comments, you need to log in
How is implication used in programming?
Can you give a simple example of an implication in Python or in pseudocode, but with real numbers instead of an abstract one?
Here is an example from the wiki, I don't understand it.
if 2 < 4: - #Это 0 для условия A
if 3 < 5: #Это 0 для условия B
if (a and b) or not a:
print('Yeeea')
def implies(a,b):
if a:
return b
else:
return True
Answer the question
In order to leave comments, you need to log in
have you looked at the wiki ?
In programming languages, implication is usually used implicitly. For example, a construction that assumes the truth of condition B in a given section of the program:if ( выражение A ) { if ( выражение B ) { сделать_что-то_полезное } else { <font color=Red>сбой</font> }; }
will succeed if and only if the implication A→B is true. At the same time, these conditions can be safely written in one line by combining them with a conjunction operator.if ( выражение A ) and ( выражение B ) { сделать_что-то_полезное }
With standard compiler options (Delphi, C++ Builder), the check goes on until the result becomes obvious, and if A is false, then (A and B) are false regardless of B, and there is no need to put another conditional operator.//выражение A - ложно if ( выражение A ) { //Дальше проверка не идет ... if ( выражение B ) { сделать_что-то_полезное } ... }
In functional languages, implication can be not only a calculation rule, but also a type of relationship between data, that is, it can be processed (including executed) and created during program execution.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question