{
  "id": "fn-array-apply",
  "dataComponent": "array",
  "heading": {
    "title": "apply",
    "badges": ["Array", "PARTIAL"]
  },
  "synopsis": "Calls a function with the elements of an array as individual arguments. Partial usage is supported for the function or the array.",
  "codeBlocks": [
    "extend(\"array\")\n\n# Basic usage:\nsput( array:apply((x,y) => x + y, [10,20]) )\n# => 30\n\n# If the array has 3 elements:\nsput( array:apply((a,b,c)=> a * b * c, [2,3,4]) )\n# => 24\n\n# If the array is empty => calls (fn) with no arguments.\nsput( array:apply(() => \"no args!\", []) )\n# => \"no args!\"\n\n# Partial usage => missing the array:\nf = array:apply((x,y,z) => x + y + z)\n# f is a partial function waiting for an array:\nsput( f([1,2,3]) )\n# => 6\n\n# Placeholder usage => known array, missing function:\npartial = array:apply(_, [7,8])\nsput( partial((x,y)=> x - y) )\n# => -1"
  ],
  "notes": [
    "Expects up to two arguments: (function, array). If both are provided, it calls function(...arrElements).",
    "If the array has `n` elements, they become `n` arguments to the function. If it’s empty, the function is called with zero arguments.",
    "Partial usage: If you only supply one argument or placeholders, it returns a partial function waiting for the missing piece. Example: `array:apply((a,b))` => returns a partial needing an array.",
    "If the second argument is not recognized as an array (int[], str[], bool[], float[]), it raises an error.",
    "Similar to Ramda’s `apply(fn, arr) => fn(...arr)` pattern."
  ]
}

