Forum Discussion
JackTradeOne
Mar 16, 2021Copper Contributor
Default values for LAMBDA parameters?
Is it possible to somehow include default values for LAMBDA functions with multiple parameters? For example, if my function is =LAMBDA(
height,
width,
height * width
); I would like to be able hav...
- Mar 16, 2021
If only as
=LAMBDA(height,width, IF(height, height,2)* width )(,4)Lambda allows optional parameters if you have more than one of them. Missed parameters are returned as zero.
JackTradeOne
Mar 16, 2021Copper Contributor
I'm not sure I understand your concept of "partially apply". The desired end result is a function (say, "Area") which I can call once as Area(,4) and get "8" in return. Does you approach achieve that?
tboulden
Mar 16, 2021Iron Contributor
Apologies, partial application is a concept from functional programming which LAMBDAs lend themselves to. Not to go to far afield, you can google it if you like.
So we have Area defined as above in Name Manager; let's define Area2:=Area(2). Now when you do Area2(4), you'll get 8. If you needed to hardcode some other value, say 4, you could define Area4:=Area(4), and Area4(2)=8.
So we have Area defined as above in Name Manager; let's define Area2:=Area(2). Now when you do Area2(4), you'll get 8. If you needed to hardcode some other value, say 4, you could define Area4:=Area(4), and Area4(2)=8.