Forum Discussion
Recamán's sequence - Recursive LAMBDA vs. REDUCE
Patrick2788 I don't have an answer, just to comment. It is a very elegant solution, I was reviewing the REDUCE approach, and how you simplified the following:
Recaman=LAMBDA(n,REDUCE(, SEQUENCE(n,,0),
LAMBDA(ac, a, GenArray(ac,a))));
replacing the second LAMBDA with the the function name. As you mentioned it is not efficient. I was thinking to use XMATCH with binary search, but the sequence is not sorted. I have seen with other similar applications of REDUCE/VSTACK pattern the same lack of performance. I would say something for Microsoft to improve. I added this feedback, in case you want to vote: Ihttps://feedbackportal.microsoft.com/feedback/idea/d90548de-bdd3-ed11-a81b-000d3a7bb563.
The Racaman sequence hasn't been studied too much compared to Fibonacci, so I could not find any indirect calculation that would avoid recursion or iteration.
- Patrick2788Apr 19, 2023Silver Contributor
davidleal Thank you for the reply. I voted for your feedback and left a comment.
re: calculation performance - I've been looking for some technical documentation on Lambda helper functions for a while. I'd like a resource that's much more in depth than the standard support page for functions. I'm interested in how the functions calculate so I can pick the best ones for the situation.
re: efficiency
I'm attaching a sample to this post where OFFSET proves to be a better option than TAKE in creating dynamic ranges for a tree map chart. It was a situation where the data could not be tabled.