Last active
January 15, 2024 18:38
-
-
Save ncalm/d31339ca6d1b10ef95fc37ded09dc0b1 to your computer and use it in GitHub Desktop.
Some simple functions for pairwise lifting of VBA UDFs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
two_arg = LAMBDA(function, | |
LAMBDA(x, y, | |
function(x, y) | |
) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Public Function multiply(x As Double, y As Double) | |
multiply = x * y | |
End Function | |
Public Function add(x As Double, y As Double) | |
add = x + y | |
End Function | |
Public Function lift(func As String, ParamArray arrs() As Variant) | |
Dim i As Long | |
Dim leadingArray As Variant | |
Dim result As Variant | |
Dim resultLength As Long | |
leadingArray = arrs(0) | |
resultLength = UBound(leadingArray) | |
ReDim result(1 To resultLength, 1 To 1) | |
For i = 1 To resultLength | |
result(i, 1) = Application.Run(func, arrs(0)(i, 1), arrs(1)(i, 1)) | |
Next i | |
lift = result | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment