{
  "id": "fn-array-reduce",
  "dataComponent": "array",
  "heading": {
    "title": "reduce",
    "badges": ["Array", "PARTIAL"]
  },
  "synopsis": "Folds (reduces) an array with a user-supplied function and initial value. Supports partial usage and underscore placeholders.",
  "codeBlocks": [
    "extend(\"array\")\\nextend(\"string\")\\n\\n# Example\\nsput(\\n  array:reduce((acc, value) => acc + value,\\n  0,\\n  [4,8,15,16,23,42])\\n)\\n// => 108\\n\\n# Partial usage\\nsumFn = (acc, x) => acc + x\\nsumReducer = array:reduce(sumFn, 0)\\nsput( sumReducer([1,2,3]) )\\n// => 6"
  ],
  "notes": [
    "Expects up to three arguments: (function, initialValue, data). Missing arguments become placeholders or partial usage.",
    "The user-supplied function is invoked for each element. Typically, the reduce-lambda uses a curried approach: first call with (acc), then call with (item).",
    "Raises an error if the data is not an int[], str[], or recognized array type."
  ]
}
