Array integer cumulative sum
array-integer-cumulative-sum · version 1.0.0 · Numbers & math · free, no key needed
Replace an array of canonical integer strings with equal-length prefix sums.
Use when you need to: array integer cumulative sum · prefix sums of integer array · running total of integer strings.
Supported
- array integer cumulative sum
- prefix sums of integer array
- running total of integer strings
Not supported
- floating point prefix sums
- moving average
- cumulative product
- mean of integers
- CSV column sums
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.
- Output values has the same length: item i is the sum of inputs 0 through i as a canonical integer string.
- An empty array yields an empty array.
- Each input and every partial sum 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 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",
"-1",
"7",
"0"
]
}
Response:
{
"result": {
"values": [
"4",
"3",
"10",
"10"
]
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "array-integer-cumulative-sum",
"version": "1.0.0",
"input": {
"values": [
"4",
"-1",
"7",
"0"
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/array-integer-cumulative-sum/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"values":["4","-1","7","0"]}'
The machine-readable contract is at /v1/tools/array-integer-cumulative-sum/versions/1.0.0.
CLI
node cli.mjs run array-integer-cumulative-sum 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Array integer median: Select lower and upper middle canonical integers; emit median only for odd length.
- Array integer mode: Return the most frequent canonical integers, listing every mode in first-seen order.
- Array integer product: Multiply an array of canonical integer strings and return the canonical product.
- Array integer sum: Sum an array of canonical integer strings and return the canonical total.
- Array rational sum: Sum an array of canonical rationals and return the reduced total.
- Array integer adjacent diff: Replace an array of canonical integer strings with consecutive first differences.