In PHP, you can do...
range(1, 3); // Array(1, 2, 3)
range(\"A\", \"C\"); // Array(\"A\", \"B\", \"C\")
That is, there is a function that l
Complete ES6 implementation using range([start, ]stop[, step]) signature:
function range(start, stop, step=1){
if(!stop){stop=start;start=0;}
return Array.from(new Array(int((stop-start)/step)), (x,i) => start+ i*step)
}
If you want automatic negative stepping, add
if(stop
Or more minimalistically:
range=(b, e, step=1)=>{
if(!e){e=b;b=0}
return Array.from(new Array(int((e-b)/step)), (_,i) => b
If you have huge ranges look at Paolo Moretti's generator approach