Closed HuwCampbell closed 4 years ago
Might be a duplicate of #146 but I can't tell
Noted. It does work in the update
branch, which uses a different approach. I'm behind on giving this attention, hope to get some time for this soon.
This is not a problem of environment but of lazy evaluation. Forcing the inputs solves the problem:
compose <- function(f, g) { force(f); force(g); function(x) g(f(x)) }
plus2 <- plus1 %>% compose(plus1)
plus2(5)
#> [1] 7
See also #195.
Fixed by #218
Sorry if this appears a little obscure, it's causing me some difficulty.
I found this issue after you posted a review for hedgehog (ta!). Using the pipe I was having infinite recursion due to the environments being brought into functions incorrectly.
Here's a quick bug showing something similar
See above that
f$value
refers tog(f(x))
, when it should befunction(x) x + 1
.