{
"id": "fn-array-ink",
"dataComponent": "array",
"heading": {
"title": "ink",
"badges": ["Array", "Lazy"]
},
"synopsis": "Creates a lazy iterator producing integer values from start (inclusive) to end (exclusive). Useful for large ranges without storing all elements in memory.",
"codeBlocks": [
"extend(\"array\")\\n\\n# Basic usage => returns an InkIterator from 5 up to (not including) 10\\ninkIter = array:ink(5, 10)\\nsput( inkIter )\\n# => <InkIterator handle> (a lazy sequence)\\n\\n# We can convert it to a real array via array:map identity or partial usage:\\nres = array:map(x => x, inkIter)\\nsput(res)\\n# => [5,6,7,8,9]\\n\\n# Or reduce it without building the entire array:\\nsumVal = array:reduce((acc,x)=>acc+x, 0, inkIter)\\nsput(sumVal)\\n# => 35\\n\\n# If you call array:ink with start >= end => no elements.\\n# In many builds, partial usage is not standard for array:ink, so you must supply both integers."
],
"notes": [
"Usage: array:ink(start, end) => returns an InkIterator that yields each integer from start (inclusive) to end (exclusive).",
"Unlike array:range, ink does not build the entire array in memory. Instead, it produces values lazily, on demand. This is beneficial for very large ranges or streaming scenarios.",
"The returned type is InkIterator, which you can pass to array:map, array:reduce, or other bridging functions that support iteration over InkIterator.",
"Both arguments must be integers. If non-integer values are passed, or if you pass fewer/more arguments, an error is raised."
]
}