Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Rockskip: simplify ruler function#62510

Merged
jtibshirani merged 2 commits into
mainfrom
jtibs/rockskip
May 8, 2024
Merged

Rockskip: simplify ruler function#62510
jtibshirani merged 2 commits into
mainfrom
jtibs/rockskip

Conversation

@jtibshirani

Copy link
Copy Markdown
Contributor

Adds a test for the ruler function and simplifies the function to remove tail
recursion.

A tiny warm-up as we work on improving Rockskip test coverage.

Test plan

Added new test case.

@cla-bot cla-bot Bot added the cla-signed label May 7, 2024
@github-actions github-actions Bot added team/product-platform team/search-platform Issues owned by the search platform team labels May 7, 2024
@jtibshirani jtibshirani requested a review from a team May 7, 2024 22:56
if n%2 != 0 {
return 0
}
return 1 + ruler(n/2)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, does go optimize away tail recursion like many functional programming languages do?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe tail-call optimization is not widely implemented (https://stackoverflow.com/questions/12102675/tail-call-optimization-in-go).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed team/product-platform team/search-platform Issues owned by the search platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants