In Lambda calculus, Y -combinator returns itself like this Y a = a Y a, specifially here. Suppose some trivial function such as y(x)=2*x+1 (suppose Church numbers for the sake of simplicity) and I want to do it Y y to which I want some sort of break-out -function. I want to do something like this
- calculate y(1) —>3
- calculate y(3) —>7
- calculate y(7) …
- …
- terminate on the n-th case
How can I do this in R using the functional way of thinking? Is there something built-in?
I don’t really understand the notation of the lambda calculus, so can’t know for sure what the Y-combinator is, but I wonder if the R function
Recall()(help page here) wouldn’t help you build what you’re after. Here is an example of its use to calculate a factorial:And here it is applied to the example you described: