Forum Discussion
Chris_Gross
Microsoft
Jan 14, 2021LAMBDA Examples: Count words in a text string
This post is the second of a series where we will be sharing out examples of lambdas. This is intended to highlight lambdas we have cooked up that show the power of this new super-charged function. A...
lori_m
Jan 17, 2021Iron Contributor
I have wondered about how to create LAMBDA functions that take a variable number of parameters. One possibility could be to define a function that takes a variable number of single arguments instead such as,
ADD:=LAMBDA(a,LAMBDA(b,IF(TYPE(b)=16,a,ADD(a+b))))
This ADD function can take scalars or arrays as parameters and returns the sum of the entries across the single arguments provided a last dummy argument is inserted. For example the following formula returns 1+2+3+4+5=15:
=ADD(1)(2)(3)(4)(5)(\)
The same sort of method could be used to extend any function from two inputs to n-inputs. For instance the a+b operation could be modified to a function UNION(a,b) that stacks two arrays so that n arrays could be stacked together. It would be nice if there were a more intuitive way to do this however 🙂