Skip to content

collatz-conjecture: write the match-recursion approach in Scala 3 syntax - #934

Merged
rabestro merged 2 commits into
mainfrom
collatz-conjecture-approaches-scala-3
Nov 13, 2026
Merged

rabestro merged 2 commits into
mainfrom
collatz-conjecture-approaches-scala-3

Conversation

@rabestro

Copy link
Copy Markdown
Member

Rewrites the match with recursion approach (the "Dig deeper" tab) in the Scala 3 syntax the track uses. The other approach moved to LazyList and Scala 3 in #928, so with this PR all of collatz-conjecture's approaches are in Scala 3.

  • Code: the states are a private enum Status (Illegal, Even, Odd, One) instead of an Enumeration. Braces and the parentheses around conditions go, getStatus takes an Int instead of a boxed Integer, and steps declares its return type. The shortened version with pattern guards names its pattern variables n.
  • Prose: the paragraph that explained the Scala 2 Enumeration and showed the Scala 3 enum as an aside now describes the enum the code uses. The case names in the text follow the code, and a typo is fixed.
  • Links: @tailrec and match point to the current docs, and two unused link definitions go.
  • The slug, uuid, title and blurb are unchanged, and the snippet stays within 8 lines.

Both versions of the approach, and the LazyList one, 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

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>
@rabestro
rabestro requested review from a team, IsaacG and glennj November 13, 2026 08:14
@rabestro rabestro self-assigned this Nov 13, 2026
@github-actions

Copy link
Copy Markdown

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)

@rabestro
rabestro requested a review from a team November 13, 2026 09:40
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>
@rabestro
rabestro merged commit 9eb305c into main Nov 13, 2026
8 checks passed
@rabestro
rabestro deleted the collatz-conjecture-approaches-scala-3 branch November 13, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants