Created
April 26, 2024 12:41
-
-
Save ncalm/3fc1f027ae8c5b550d96e7e014248c6f to your computer and use it in GitHub Desktop.
This Excel LAMBDA function implements the functionality of F#'s List.allPairs function for creating a cross-join between two lists (vectors)
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
LIST.ALLPAIRS = LAMBDA(list1, list2, | |
LET( | |
list1Col, TOCOL(list1), | |
list2Col, TOCOL(list2), | |
list1length, ROWS(list1Col), | |
list2length, ROWS(list2Col), | |
resultRows, SEQUENCE(list1length * list2length, 1), | |
rowIndex1, CEILING(resultRows / list2length, 1), | |
rowIndex2, MOD(resultRows - 1, list2length) + 1, | |
HSTACK(INDEX(list1Col, rowIndex1), INDEX(list2Col, rowIndex2)) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment