Short-circuit evaluation: Difference between revisions
Content added Content deleted
(→Insitux: inclusion) |
(Added Easylang) |
||
Line 1,226: | Line 1,226: | ||
<syntaxhighlight lang="e">def x := a(i) && (def funky := b(j))</syntaxhighlight> |
<syntaxhighlight lang="e">def x := a(i) && (def funky := b(j))</syntaxhighlight> |
||
The choice we make is that <code>funky</code> is ordinary if the right-side expression was evaluated, and otherwise is <em>ruined</em>; attempts to access the variable give an error. |
The choice we make is that <code>funky</code> is ordinary if the right-side expression was evaluated, and otherwise is <em>ruined</em>; attempts to access the variable give an error. |
||
=={{header|EasyLang}}== |
|||
<syntaxhighlight lang=easylang> |
|||
func a x . |
|||
print "->a: " & x |
|||
return x |
|||
. |
|||
func b x . |
|||
print "->b: " & x |
|||
return x |
|||
. |
|||
print "1 and 1" |
|||
if a 1 = 1 and b 1 = 1 |
|||
print "-> true" |
|||
. |
|||
print "" |
|||
print "1 or 1" |
|||
if a 1 = 1 or b 1 = 1 |
|||
print "-> true" |
|||
. |
|||
print "" |
|||
print "0 and 1" |
|||
if a 0 = 1 and b 1 = 1 |
|||
print "-> true" |
|||
. |
|||
print "" |
|||
print "0 or 1" |
|||
if a 0 = 1 or b 1 = 1 |
|||
print "-> true" |
|||
. |
|||
</syntaxhighlight> |
|||
=={{header|Ecstasy}}== |
=={{header|Ecstasy}}== |