September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
29
Task/Currying/Visual-Basic-.NET/currying-2.visual
Normal file
29
Task/Currying/Visual-Basic-.NET/currying-2.visual
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
Module Main
|
||||
' An example binary function.
|
||||
Function Add(a As Integer, b As Integer) As Integer
|
||||
Return a + b
|
||||
End Function
|
||||
|
||||
Sub Main()
|
||||
Dim curriedAdd = Curry(Of Integer, Integer, Integer)(AddressOf Add)
|
||||
Dim add2To = curriedAdd(2)
|
||||
|
||||
Console.WriteLine(Add(2, 3))
|
||||
Console.WriteLine(add2To(3))
|
||||
Console.WriteLine(curriedAdd(2)(3))
|
||||
|
||||
' An example ternary function.
|
||||
Dim substring = Function(s As String, startIndex As Integer, length As Integer) s.Substring(startIndex, length)
|
||||
Dim curriedSubstring = Curry(substring)
|
||||
|
||||
Console.WriteLine(substring("abcdefg", 2, 3))
|
||||
Console.WriteLine(curriedSubstring("abcdefg")(2)(3))
|
||||
|
||||
' The above is just syntax sugar for this (a call to the Invoke() method of System.Delegate):
|
||||
Console.WriteLine(curriedSubstring.Invoke("abcdefg").Invoke(2).Invoke(3))
|
||||
|
||||
Dim substringStartingAt1 = curriedSubstring("abcdefg")(1)
|
||||
Console.WriteLine(substringStartingAt1(2))
|
||||
Console.WriteLine(substringStartingAt1(4))
|
||||
End Sub
|
||||
End Module
|
||||
Loading…
Add table
Add a link
Reference in a new issue