Skip to content

Instantly share code, notes, and snippets.

@ncalm
Last active January 15, 2024 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ncalm/d31339ca6d1b10ef95fc37ded09dc0b1 to your computer and use it in GitHub Desktop.
Save ncalm/d31339ca6d1b10ef95fc37ded09dc0b1 to your computer and use it in GitHub Desktop.
Some simple functions for pairwise lifting of VBA UDFs
two_arg = LAMBDA(function,
LAMBDA(x, y,
function(x, y)
)
);
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