Array integer clamp
array-integer-clamp · version 1.0.0 · Numbers & math · free, no key needed
Clamp an array of canonical integer strings to optional inclusive min and max bounds.
Use when you need to: array integer clamp · clamp integer array to bounds · bound integer values by min and max.
Supported
- array integer clamp
- clamp integer array to bounds
- bound integer values by min and max
Not supported
- floating point clamp
- percentile clipping
- outlier detection
- interpolate out-of-range values
- CSV column clamp
Behavior
- Input values is an array of at most 10000 canonical integer strings.
- A canonical integer is 0 or an optional ASCII minus followed by a non-zero leading digit and only digits after that.
- Input -0 is accepted and canonicalized to 0; +, spaces, underscores, hex, exponents, empty strings, and other leading zeros are rejected.
- Integers are parsed with BigInt. IEEE-754 numbers are rejected.
- At least one of min and max is required. When present they are canonical integer strings.
- When both bounds are present, min must be less than or equal to max.
- Each output value is min if below min, max if above max, otherwise the canonicalized input.
- An empty values array is allowed.
- Each input, min, and max may have at most 1000 digits excluding the sign.
Input
values(array of string, required): max items 10000; each min length 1; each max length 1001min(string, optional): min length 1; max length 1001max(string, optional): min length 1; max length 1001
Output
values(array of string, required): max items 10000; each max length 1001; each pattern^(0|-?[1-9][0-9]*)$
Limits
- max items: 10000
- max digits: 1000
Example
Request input:
{
"values": [
"-4",
"2",
"9",
"15"
],
"min": "0",
"max": "10"
}
Response:
{
"result": {
"values": [
"0",
"2",
"9",
"10"
]
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "array-integer-clamp",
"version": "1.0.0",
"input": {
"values": [
"-4",
"2",
"9",
"15"
],
"min": "0",
"max": "10"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/array-integer-clamp/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"values":["-4","2","9","15"],"min":"0","max":"10"}'
The machine-readable contract is at /v1/tools/array-integer-clamp/versions/1.0.0.
CLI
node cli.mjs run array-integer-clamp 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Array integer min max: Return the numeric minimum and maximum of canonical integer strings.
- Array rational min max: Return the reduced numeric minimum and maximum of an array of canonical rationals.
- Array integer median: Select lower and upper middle canonical integers; emit median only for odd length.
- Array integer adjacent diff: Replace an array of canonical integer strings with consecutive first differences.
- Array integer cumulative sum: Replace an array of canonical integer strings with equal-length prefix sums.
- Array integer GCD: Compute the non-negative greatest common divisor of an array of canonical integer strings.