$range(count)

$range(start, end[, step])

Generates a sequence of integral numbers within a specified range.

Syntax

Parameters

count
Type: number
The number of sequential integers to generate.
start
Type: number
The value of the first integer in the sequence.
end
Type: number
The value of the last integer in the sequence. (exclusive)
step
Type: number
Increasing steps from start to end - 1.
Return Value

An iteratable object that will iterate consequence values from 0 to count - 1, or from start to end - 1.

Examples

var squares = $range(4).select("$ * $");
squares.each("document.writeln($)");

/*
 This code produces the following output:
 0
 1
 4
 9
*/

// Generate a sequence of three integers starting at 4, 
// and then select their squares.
var squares = $range(4, 7).select("$ * $");
squares.each("document.writeln($)");

/*
 This code produces the following output:
 16
 25
 36
*/

var squares = $range(3, 13, 3).select("$ * $");
squares.each("document.writeln($)");

/*
 This code produces the following output:
 9
 36
 81
 144
*/

Last edited May 18, 2012 at 11:13 AM by suckgamoni, version 1

Comments

No comments yet.