Using Number Ranges

As of version 8 of TEM, you can use number ranges in a variety of ways. To generate the first four numbers, you could use an expression like the following:

Q: integers to (3)
A: 0
A: 1
A: 2
A: 3

Note that the index is zero-based, so the range goes from 0-3, not 1-3. You can use negative numbers as well:

Q: integers in (-2, 2)
A: -2
A: -1
A: 0
A: 1
A: 2

As well as listing numbers incrementally by one, you can also specify a step size:

Q: integers in (-10, 3, 3)
A: -10
A: -7
A: -4
A: -1
A: 2

This expression goes from the first value (-10) in steps of three, stopping at the first integer that doesn't exceed the final value. You can derive the final value from the length of a string, as in this example:

Q: integers in ((0, length of it, 2) of "00000b000100")
A: 0
A: 2
A: 4
A: 6
A: 8
A: 10
A: 12

Note that the length is 12, and the integers command is inclusive of the endpoints, so it includes a pointer to the end of the string.

Q: concatenation "," of substrings (integers in (0, length of it, 2), 2) of 
"00000b00010002000000000000000000"
A: 00,00,0b,00,01,00,02,00,00,00,00,00,00,00,00,00

Here is a more complicated example that combines two lists. The first list is numeric (1, 2, 3) and the second list is alphabetic (a, b, c). This expression combines the two to produce (1a, 2b, 3c):

Q: substrings (integers in (0, length of it, 2) , 2) of (concatenation of 
substrings ((item 0 of it ; item 0 of it + item 1 of it) of (positions of 
first ((length of it - 1) / 2) of it, length of it / 2), 1) of it) of 
concatenation of (("1";"2";"3"); ("a";"b";"c"))
A: 1a
A: 2b
A: 3c

The expression makes good use of the "item N of it" syntax for indexing into a list of objects.