Array Interleave merges two arrays by alternating their elements into a single array. Use via MCP in Cursor or Windsurf, or call GET /v1/array/interleave with array1 and array2 parameters. Example: [1,2,3] + [a,b,c] becomes [1,a,2,b,3,c]. Handles arrays of different lengths by appending remaining elements.
curl "https://tinyfn.io/v1/array/interleave" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/array/interleave', {
headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests
response = requests.get('https://tinyfn.io/v1/array/interleave',
headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)
Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's array tools:
{
"mcpServers": {
"tinyfn-array": {
"url": "https://tinyfn.io/mcp/array",
"headers": {
"X-API-Key": "YOUR_API_KEY"
}
}
}
}
The function alternates elements until the shorter array is exhausted, then appends all remaining elements from the longer array to the result.
Yes, you can interleave arrays containing strings, numbers, booleans, or mixed types. The output preserves the original data types of each element.
Concatenation joins arrays end-to-end ([1,2] + [3,4] = [1,2,3,4]), while interleaving alternates elements ([1,2] + [3,4] = [1,3,2,4]).
Ask your AI assistant to interleave two arrays, and it will call the TinyFn tool automatically. Works in Cursor, Claude Code, and other MCP-supported editors.
Interleaving with an empty array returns the non-empty array unchanged. Interleaving two empty arrays returns an empty array.
Get your free API key and start using Array Interleave in seconds.
Get Free API Key