{
"id": "fn-flow-to_array",
"dataComponent": "flow",
"heading": {
"title": "to_array",
"badges": [
"Flow"
]
},
"synopsis": "Consumes an InkIterator or InkTransform to produce a final in-memory array of items. Fails if the items are of mixed or unsupported types.",
"codeBlocks": [
"extend(\"flow\")\n\n# 1) Direct usage with an InkIterator\nnums = flow:to_array( ink(1,5) )\nsput(nums)\n# => [1,2,3,4]\n\n# 2) With an InkTransform => e.g. flow:trans\nxf = flow:trans(x => x*2, ink(2,5))\narr = flow:to_array(xf)\nsput(arr)\n# => [4,6,8]\n\n# 3) If the iteration yields a mix of ints, floats, or strings, bridging may raise an error or handle partial upcasting. Usually all items must unify to a single array type.\n"
],
"notes": [
"Takes exactly one argument => (source). The source must be an InkIterator or an InkTransform.",
"It repeatedly retrieves items until 'NO_MORE_DATA', gathering them into an int_array, float_array, or str_array if uniform. Mixed types cause an error unless your bridging code supports a generic array.",
"This is a final stage that pulls the entire stream into memory. For extremely large streams, consider using partial consumption or separate techniques if memory is a concern."
]
}