I have a function which takes as arguments named tuples. But I’m struggling to get it work as I would hope. As a minimal working example consider.
function test(x; a=1.0, b=1.0, c=1.0) return x + a + 5*b + 10*c end
If I run
test(1.0) I get 17.0 as expected. If I run
test(1.0, b=10.0, c=10.0) I get 151.0 as expected. But what I would really like is to define a named tuple as a subset of a,b,c and produce output as in the previous examples.
If I create
named_tuple = (b=10.0, c=10.0) and run
test(1.0, named_tuple...) I get back 17.0 which is just
test evaluated at the default values.
In my actual problem I have a function that takes in many named arguments with default values but with the flexibility to specify different values should I wish. I’m creating a subset of named arguments by iterating through the names and values of a data frame and trying to evaluate my function.
Any help would be very much appreciated.