Skip to content

feat(micro-utilities): add compute-lcm to replacements - #1231

Open
Rutvij97 wants to merge 3 commits into
e18e:mainfrom
Rutvij97:feat/compute-lcm
Open

Rutvij97 wants to merge 3 commits into
e18e:mainfrom
Rutvij97:feat/compute-lcm

Conversation

@Rutvij97

@Rutvij97 Rutvij97 commented Nov 11, 2026 •

Copy link
Copy Markdown

🔗 Linked issue

Resolves #1208

📚 Description

Adds compute-lcm to the micro-utilities manifest with a snippet::lcm replacement.

The snippet takes any number of integers and reduces over them with a small gcd helper, which is included so the example stands on its own. compute-lcm also accepts an array plus an accessor and validates its inputs; lcm(...arr) or lcm(...arr.map(accessor)) covers the array case, and the snippet does not replace the input validation.

Comment thread manifests/micro-utilities.json Outdated
"snippet::lcm": {
"id": "snippet::lcm",
"type": "simple",
"description": "You can compute the least common multiple by dividing the product of two integers by their greatest common divisor (found with the Euclidean algorithm), and reduce over the inputs for more than two values.",

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.

your agent seems to mistakingly think we care what algorithm was used. let's remove that unnecessary information

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed the algorithm wording in c11ce37 and trimmed the PR description. Noted on reading the diff before opening PRs, thanks.

@43081j

43081j commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

@Rutvij97 for future PRs, can you review your code beforehand, never trust your agent. today your agent and 3 others have leaked thoughts into these descriptions and it is time consuming for me to explain that in reviews.

if you, the human, read the PR then you can fix it before i get to it.

@maksimgm

Copy link
Copy Markdown
Contributor

this conflicts with main now that compute-gcd landed. small thing: lcm(-7) returns -7 since reduce skips the callback with one value, compute-lcm returns null there

@Rutvij97

Copy link
Copy Markdown
Author

Pushed 41d4f3a with current main merged, retaining the compute-gcd mapping. The LCM helper now returns null for fewer than two values, including lcm(-7). Full formatting/manifest validation and the TypeScript build passed; eight additional cases covered empty/singleton input, negative values, zeros and multiple arguments.

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.

[Replacement]: compute-lcm

3 participants