September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -1,21 +1,23 @@
|
|||
import system'routines.
|
||||
import extensions.
|
||||
import system'routines;
|
||||
import extensions;
|
||||
|
||||
symbol a = (:x)[ console writeLine:"a". ^ x. ].
|
||||
Func<bool, bool> a = (bool x){ console.writeLine:"a"; ^ x };
|
||||
|
||||
symbol b = (:x)[ console writeLine:"b". ^ x. ].
|
||||
Func<bool, bool> b = (bool x){ console.writeLine:"b"; ^ x };
|
||||
|
||||
program =
|
||||
[
|
||||
(false, true) forEach(:i)
|
||||
[
|
||||
(false, true) forEach(:j)
|
||||
[
|
||||
console printLine(i," and ",j," = ",a(i) && $(b(j))).
|
||||
const bool[] boolValues = new bool[] { false, true };
|
||||
|
||||
console writeLine.
|
||||
console printLine(i," or ",j," = ",a(i) || $(b(j))).
|
||||
console writeLine.
|
||||
].
|
||||
].
|
||||
].
|
||||
public program()
|
||||
{
|
||||
boolValues.forEach:(bool i)
|
||||
{
|
||||
boolValues.forEach:(bool j)
|
||||
{
|
||||
console.printLine(i," and ",j," = ",a(i) && b(j));
|
||||
|
||||
console.writeLine();
|
||||
console.printLine(i," or ",j," = ",a(i) || b(j));
|
||||
console.writeLine()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
Private Function a(i As Variant) As Boolean
|
||||
Debug.Print "a: "; i = 1,
|
||||
a = i
|
||||
End Function
|
||||
Private Function b(j As Variant) As Boolean
|
||||
Debug.Print "b: "; j = 1;
|
||||
b = j
|
||||
End Function
|
||||
Public Sub short_circuit()
|
||||
Dim x As Boolean, y As Boolean
|
||||
'Dim p As Boolean, q As Boolean
|
||||
Debug.Print "=====AND=====" & vbCrLf
|
||||
For p = 0 To 1
|
||||
For q = 0 To 1
|
||||
If a(p) Then
|
||||
x = b(q)
|
||||
End If
|
||||
Debug.Print " = x"
|
||||
Next q
|
||||
Debug.Print
|
||||
Next p
|
||||
Debug.Print "======OR=====" & vbCrLf
|
||||
For p = 0 To 1
|
||||
For q = 0 To 1
|
||||
If Not a(p) Then
|
||||
x = b(q)
|
||||
End If
|
||||
Debug.Print " = x"
|
||||
Next q
|
||||
Debug.Print
|
||||
Next p
|
||||
Debug.Print
|
||||
End Sub
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
Module Module1
|
||||
|
||||
Function A(v As Boolean) As Boolean
|
||||
Console.WriteLine("a")
|
||||
Return v
|
||||
End Function
|
||||
|
||||
Function B(v As Boolean) As Boolean
|
||||
Console.WriteLine("b")
|
||||
Return v
|
||||
End Function
|
||||
|
||||
Sub Test(i As Boolean, j As Boolean)
|
||||
Console.WriteLine("{0} and {1} = {2} (eager evaluation)", i, j, A(i) And B(j))
|
||||
Console.WriteLine("{0} or {1} = {2} (eager evaluation)", i, j, A(i) Or B(j))
|
||||
Console.WriteLine("{0} and {1} = {2} (lazy evaluation)", i, j, A(i) AndAlso B(j))
|
||||
Console.WriteLine("{0} or {1} = {2} (lazy evaluation)", i, j, A(i) OrElse B(j))
|
||||
|
||||
Console.WriteLine()
|
||||
End Sub
|
||||
|
||||
Sub Main()
|
||||
Test(False, False)
|
||||
Test(False, True)
|
||||
Test(True, False)
|
||||
Test(True, True)
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
Loading…
Add table
Add a link
Reference in a new issue