Anonymous user
Short-circuit evaluation: Difference between revisions
→{{header|Icon}}: better example
(→Icon and Unicon: comments) |
(→{{header|Icon}}: better example) |
||
Line 126:
==={{header|Icon}}===
<lang Icon>procedure main()
&trace := -1 # ensures a and b print their names▼
every (i := &null | 1 ) & ( j := &null | 1) do {▼
write("i,j := ",image(i),", ",image(j))
write("
x :=
write("
y :=
}
end
return
end
procedure false()
fail # for clarity but not needed as running into end has the same effect
end
rtcircuit.icn: 8 | false()
rtcircuit.icn: 16 | true returned &null
i,j := procedure true, procedure true</pre>
▲procedure b(x)
▲end</lang>
▲Sample output for a single case:<pre>i,j := &null, 1
▲a & b:
▲shortcicuit.icn: 10 | a(&null)
▲shortcicuit.icn: 19 | a failed
▲a | b:
▲shortcicuit.icn: 12 | b(1)
▲shortcicuit.icn: 23 | b returned 1</pre>
==={{header|Unicon}}===
The Icon solution works in Unicon.
|