"Sputnik" help  
Sputnik Help
Language Reference - Operators - Operator rr (Range)

Operator rr

Range operator.

The first action of this operator is the ability to make ranges of stuff and these ranges may be either a string or an array.

In this example we make a range of the chars from A to F:

// String form
say 'A' rr 'F';
// Array form
printr array('A' rr 'F');
// PRINTS
// ABCDEF
// Array
// (
//     [0] => A
//     [1] => B
//     [2] => C
//     [3] => D
//     [4] => E
//     [5] => F
// )

You can also join multiple ranges together example:

// String form
say ('A' rr 'F') . ('0' rr '3');
// Array form
printr array('A' rr 'F', '0' rr '3');
// PRINTS
// ABCDEF0123
// Array
// (
//     [0] => A
//     [1] => B
//     [2] => C
//     [3] => D
//     [4] => E
//     [5] => F
//     [6] => 0
//     [7] => 1
//     [8] => 2
//     [9] => 3
// )

Ranges may go backwards like:

// String form
say ('F' rr 'A') . ('3' rr '0');
// Array form
printr array('F' rr 'A', '3' rr '0');
// PRINTS
// FEDCBA3210
// Array
// (
//     [0] => F
//     [1] => E
//     [2] => D
//     [3] => C
//     [4] => B
//     [5] => A
//     [6] => 3
//     [7] => 2
//     [8] => 1
//     [9] => 0
// )

You can also do Numeric changes (cannot be floating points):

// String form
say (0 rr 3) . (4 rr 2);
// Array form
printr array(0 rr 3, 4 rr 2);
// PRINTS
// 0123432
// Array
// (
//     [0] => 0
//     [1] => 1
//     [2] => 2
//     [3] => 3
//     [4] => 4
//     [5] => 3
//     [6] => 2
// )

And finally a range may be variables:

/// Define some variables
my $a = 0;
my $b = 3;
my $c = 'T';
my $d = 'Z';
// String form
say ($a rr $b) . ($c rr $d);
// Array form
printr array($a rr $b, $c rr $d);
// PRINTS
// 0123TUVWXYZ
// Array
// (
//     [0] => 0
//     [1] => 1
//     [2] => 2
//     [3] => 3
//     [4] => T
//     [5] => U
//     [6] => V
//     [7] => W
//     [8] => X
//     [9] => Y
//     [10] => Z
// )

To see a list of all the operators go here.


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org