Repository navigation
feat(math): let math.max and math.min take one expression matching many numbers - #445
Merged
Merged
Conversation
…ny numbers math.max:x:@.numbers/* used to read only the first matched value as its base, so the largest value in a list needed a loop. Without children, a value expression now supplies every operand, one per matched node, and an expression matching no nodes throws. Calls with children behave as before. The two slots get ExtremumSignature, which declares one operand or more, so the slot check accepts the list form. The other arithmetic slots keep two or more. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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.



What
math.maxandmath.minnow accept a single value expression that matches many nodes, and return the largest or smallest of all of them:Before, the expression was read as one base operand, so finding the largest value in a list needed a
for-eachloop.How
Utilities.AllOperands(): without children, a value expression supplies every operand, one per matched node. An expression matching no nodes throws aHyperlambdaException. With children, the operands are the base plus the children, as before.Max.csandMin.csuse it. Their value descriptions mention the list form.ExtremumSignatureinheritsArithmeticSignatureand only changes the operand count to one or more, sohyperlambda.verify-slotsaccepts the list form.math.add,math.subtract,math.multiply,math.divideandmath.modulokeep two or more.Why
In the generator eval the Gemma fine-tune wrote exactly this form for test 120 ("return the largest value in a list") and the slot check rejected it. With this change the generated code verifies and passes.
Tests
magic.lambda.math.tests: 81 passed. New cases: a list of ints formath.max, a list of decimals formath.min, a single matched node, and an empty match that must throw. The signature test now expects one or more operands formath.maxandmath.min.🤖 Generated with Claude Code