JavaScript implementation of Python xrange() builtin

1
2
3
4
5
6
7
8
9
function xrange(b0, b1, quantum) {
	if (!quantum) { quantum = 1; }
	if (!b1) { b1 = b0; b0 = 0; }
	out = [];
	for (var i = b0, idx = 0; i < b1; i += quantum, idx++) {
		out[idx] = i;
	}
	return out;
}

More like this

  1. Use git log to give your app a revision by peterbe 3 years, 6 months ago
  2. Python-like string interpolation in Javascript by phxx 2 years, 11 months ago
  3. Dynamical formsets by I159 1 year, 6 months ago
  4. Export Django data to datestamped tarball -- choose individual models for handy packaging and archiving by fish2000 2 years, 8 months ago
  5. Client-side Django-style date & time string formatting by robbie 6 years, 2 months ago

Comments

(Forgotten your password?)