Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,8 @@
|
|||
Partial Module Program
|
||||
' Stop and Step are language keywords and must be escaped with brackets.
|
||||
Iterator Function Range(start As Integer, [stop] As Integer, Optional [step] As Integer = 1) As IEnumerable(Of Integer)
|
||||
For i = start To [stop] Step [step]
|
||||
Yield i
|
||||
Next
|
||||
End Function
|
||||
End Module
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
Imports System.Globalization
|
||||
|
||||
Partial Module Program
|
||||
Sub Main()
|
||||
' All variables are inferred to be of type Integer.
|
||||
Dim prod = 1,
|
||||
sum = 0,
|
||||
x = +5,
|
||||
y = -5,
|
||||
z = -2,
|
||||
one = 1,
|
||||
three = 3,
|
||||
seven = 7
|
||||
|
||||
' The exponent operator compiles to a call to Math.Pow, which returns Double, and so must be converted back to Integer.
|
||||
For Each j In Range(-three, CInt(3 ^ 3), 3 ).
|
||||
Concat(Range(-seven, +seven, x )).
|
||||
Concat(Range(555, 550 - y )).
|
||||
Concat(Range(22, -28, -three)).
|
||||
Concat(Range(1927, 1939 )).
|
||||
Concat(Range(x, y, z )).
|
||||
Concat(Range(CInt(11 ^ x), CInt(11 ^ x) + one ))
|
||||
|
||||
sum = sum + Math.Abs(j)
|
||||
If Math.Abs(prod) < 2 ^ 27 AndAlso j <> 0 Then prod = prod * j
|
||||
Next
|
||||
|
||||
' The invariant format info by default has two decimal places.
|
||||
Dim format As New NumberFormatInfo() With {
|
||||
.NumberDecimalDigits = 0
|
||||
}
|
||||
|
||||
Console.WriteLine(String.Format(format, " sum= {0:N}", sum))
|
||||
Console.WriteLine(String.Format(format, "prod= {0:N}", prod))
|
||||
End Sub
|
||||
End Module
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<Runtime.CompilerServices.Extension>
|
||||
Function ConcatRange(source As IEnumerable(Of Integer), start As Integer, [stop] As Integer, Optional [step] As Integer = 1) As IEnumerable(Of Integer)
|
||||
Return source.Concat(Range(start, [stop], [step]))
|
||||
End Function
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
For Each j In Range(-three, CInt(3 ^ 3), 3 ).
|
||||
ConcatRange(-seven, +seven, x ).
|
||||
ConcatRange(555, 550 - y ).
|
||||
ConcatRange(22, -28, -three).
|
||||
ConcatRange(1927, 1939 ).
|
||||
ConcatRange(x, y, z ).
|
||||
ConcatRange(CInt(11 ^ x), CInt(11 ^ x) + one )
|
||||
Next
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
Function Range(ParamArray ranges() As (start As Integer, [stop] As Integer, [step] As Integer)) As IEnumerable(Of Integer)
|
||||
' Note: SelectMany is equivalent to bind, flatMap, etc.
|
||||
Return ranges.SelectMany(Function(r) Range(r.start, r.stop, r.step))
|
||||
End Function
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
For Each j In Range((-three, CInt(3 ^ 3), 3 ),
|
||||
(-seven, +seven, x ),
|
||||
(555, 550 - y, 1 ),
|
||||
(22, -28, -three ),
|
||||
(1927, 1939, 1 ),
|
||||
(x, y, z ),
|
||||
(CInt(11 ^ x), CInt(11 ^ x) + one, 1 ))
|
||||
Next
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
Function Range(ParamArray ranges As Integer()()) As IEnumerable(Of Integer)
|
||||
Return ranges.SelectMany(Function(r) Range(r(0), r(1), If(r.Length < 3, 1, r(2))))
|
||||
End Function
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
For Each j In Range({-three, CInt(3 ^ 3), 3 },
|
||||
{-seven, +seven, x },
|
||||
{555, 550 - y },
|
||||
{22, -28, -three },
|
||||
{1927, 1939 },
|
||||
{x, y, z },
|
||||
{CInt(11 ^ x), CInt(11 ^ x) + one })
|
||||
Next
|
||||
Loading…
Add table
Add a link
Reference in a new issue