Skip to content

feat(math): let math.max and math.min take one expression matching many numbers - #445

Merged
polterguy merged 1 commit into
masterfrom
feat/math-max-min-expression
Nov 19, 2026
Merged

polterguy merged 1 commit into
masterfrom
feat/math-max-min-expression

Conversation

@polterguy

Copy link
Copy Markdown
Owner

What

math.max and math.min now accept a single value expression that matches many nodes, and return the largest or smallest of all of them:

math.max:x:@.arguments/*/numbers/*

Before, the expression was read as one base operand, so finding the largest value in a list needed a for-each loop.

How

  • Utilities.AllOperands(): without children, a value expression supplies every operand, one per matched node. An expression matching no nodes throws a HyperlambdaException. With children, the operands are the base plus the children, as before.
  • Max.cs and Min.cs use it. Their value descriptions mention the list form.
  • ExtremumSignature inherits ArithmeticSignature and only changes the operand count to one or more, so hyperlambda.verify-slots accepts the list form. math.add, math.subtract, math.multiply, math.divide and math.modulo keep 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 for math.max, a list of decimals for math.min, a single matched node, and an empty match that must throw. The signature test now expects one or more operands for math.max and math.min.

🤖 Generated with Claude Code

…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>
@sonarqubecloud

Copy link
Copy Markdown

@polterguy
polterguy merged commit b013833 into master Nov 19, 2026
9 checks passed
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.

1 participant