Hi, I often find myself in argument .fists = FALSEto purrr:partial. So today I decided to stop repeating myself, and I tried to write a partial himself partial:
backwards_partial <- partial(partial,.first = FALSE)
This function made me nervous quite quickly, because it is ambiguous as to how it will be used .first = FALSE:
- as the default parameter of the function being output
- as an argument to the caller particle that will move the pre-populated arguments to the end of the output function
I thought I could fix this ambiguity by writing this:
backwards_partial <- lift_ld(lift_dl(partial),list(.first = FALSE))
But this failed, and it does not look elegant.
So my question is ...
Is there a proper way (best practice, community standard) that I'm missing here?
If so, what is it?
Otherwise, how would you solve this problem?
EDIT:
I have to mention my use case for backwards_partial.
I am looking to pre-populate the arguments of several functions that I will pass in compose, which will pass the results of the previous function to the first argument, therefore .fists = FALSEensures that we do not overwrite the pre-populated arguments.
source
share