Repository navigation
collatz-conjecture: write the match-recursion approach in Scala 3 syntax - #934
Merged
Merged
Conversation
The approach defines its states with an enum instead of an Enumeration, so the prose no longer explains the Scala 2 way first. The code drops braces and parentheses around conditions, `getStatus` takes an `Int` instead of a boxed `Integer`, `steps` declares its return type, and the shortened version names its pattern variables `n`. The tailrec link points to the current docs. Each version of the approach passes the current test suite. [no important files changed] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Hello 👋 Thanks for your PR. This repo does not currently have dedicated maintainers. Our cross-track maintainers team will attempt to review and merge your PR, but it will likely take longer for your PR to be reviewed. If you enjoy contributing to Exercism and have a track-record of doing so successfully, you might like to become an Exercism maintainer for this track. Please feel free to ask any questions, or chat to us about anything to do with this PR or the reviewing process on the Exercism forum. (cc @exercism/cross-track-maintainers) |
glennj
reviewed
Nov 13, 2026
glennj
approved these changes
Nov 13, 2026
scalafmt splits the alignment group around the guards, so the page aligns them by hand. [no important files changed] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rewrites the
matchwith recursion approach (the "Dig deeper" tab) in the Scala 3 syntax the track uses. The other approach moved toLazyListand Scala 3 in #928, so with this PR all of collatz-conjecture's approaches are in Scala 3.private enum Status(Illegal, Even, Odd, One) instead of anEnumeration. Braces and the parentheses around conditions go,getStatustakes anIntinstead of a boxedInteger, andstepsdeclares its return type. The shortened version with pattern guards names its pattern variablesn.Enumerationand showed the Scala 3enumas an aside now describes theenumthe code uses. The case names in the text follow the code, and a typo is fixed.@tailrecandmatchpoint to the current docs, and two unused link definitions go.Both versions of the approach, and the
LazyListone, pass the current test suite. The code is formatted with the track's scalafmt config.This doesn't change the tests or the stub:
[no important files changed].Part of #914.
🤖 Generated with Claude Code