I have a simple function which has default values.
foo[a_: 1, b_: 2, c_: 3] := a + b + c
To evaluate it, I need to provide the arguments in the same positional order in which the function was constructed. For instance,
f[1, 2, 3] or
f[a = 1, b = 2, c = 3] or
f[a = 1, b = 2] will be equal to 6.
However, in some situations you may want to change the value of
c, but use the default value for
b. You then must type the default value, and remember the argument positions, which becomes tedious if there are many arguments.
Is there a way to only provide function the modified arguments and evaluate it like say
f[a = 1, c = 5] (make it show 8 instead of 9) such that it fills in the remaining default positions itself?
My idea was to create a keyword list and position match the argument string keys and use them as inputs. But, it also has a lot of problems: for instance, default values should be included and at times replaced in the keyword list.