Is it possible to create a function with a "for loop" style syntax? And if so, what would that style of function be called?
For example a for loop follows this syntax:
for(i = 0; i < 10; i++)
{
//do something
}
Is it possible in any language to create your own function, for example, called "myFunction" that could be called like this:
myFunction(x; y; z)
{
//do something
}
(Notice the semicolons instead of commas for the function inputs and then the block wrapper)
Normally in programming languages you can only create a function and call it like this:
myFunction(input1, input2, input2);
So basically I want to be able to create a function that accepts inputs, separated by semicolons and a block of code in the same way that a for loop does. Is this possible? What is this called?
Edit - CLARIFICATION: I'm not looking to write a shortcut function that runs a loop. I'm looking to write a made up function, that from a syntax standpoint, looks like a for loop. However, the made up function will never ever call "for" or for any reason.
Edit - Would this be possible to implement at the "compiler" level? I understand the closest thing in JavaScript would be the following (but it isn't as clean as a for):
myFunction(x, y, z, function()
{
//do something
});