Difference between revisions of "User:8680/tmp/AnimationWMLProgressiveStringSquareBracketExpansionSyntax"
(Created page with "Each set of square brackets (‘[’ and ‘]’) contains a comma-separated list — an '''''expansion list''''' — of which each element can be: # a plain '''string''' —...") |
|||
Line 1: | Line 1: | ||
Each set of square brackets (‘[’ and ‘]’) contains a comma-separated list — an '''''expansion list''''' — of which each element can be: | Each set of square brackets (‘[’ and ‘]’) contains a comma-separated list — an '''''expansion list''''' — of which each element can be: | ||
− | # a | + | # a '''plain string''' — e.g., “abc” or “123”; |
# a '''range''', expressed as two radix-10 integers, separated by a tilde — e.g., “1~5”; or | # a '''range''', expressed as two radix-10 integers, separated by a tilde — e.g., “1~5”; or | ||
# a '''repetition''', notated as a string and a radix-10 integer, separated by an asterisk — e.g., “a*3”. | # a '''repetition''', notated as a string and a radix-10 integer, separated by an asterisk — e.g., “a*3”. | ||
− | + | Ranges can not only be from a lesser number to a greater number (e.g., “1~5”), but can also be backward — from a greater number to a lesser number (e.g., “5~1”). | |
− | A single progressive string value may contain multiple expansion lists, which must all be of the same length in elements. | + | ====== Range expansion ===== |
+ | |||
+ | Each '''range''' ''x~y'' is expanded within its expansion list to a comma-separated list of radix-10 integers (which are plain strings), starting from the first endpoint ''x'' and ending at the second endpoint ''y''. | ||
+ | |||
+ | If ''x'' < ''y'', then the numbers in this list increase by increments of 1; if ''x'' > ''y'', then the numbers in this list decrease by decrements of 1. E.g., “1~3” would become “1,2,3”, and “3~1” would become “3,2,1”. | ||
+ | |||
+ | If ''x'' = ''y'', then this list has only one element, which is ''x''. E.g., “2~2” would becomes “2”. | ||
+ | |||
+ | If either ''x'' or ''y'' are padded with leading zeros, then each number in the resultant list will be padded with leading zeros such that it is expressed in as many digits as the endpoint (either of ''x'' or ''y'') that is padded with the most leading zeros. E.g., “07~11” would become “07,08,09,10,11”, and “003~1” would become “003,002,001”. | ||
+ | |||
+ | ====== Square bracket expansion ====== | ||
+ | |||
+ | A single progressive string value may contain multiple square-bracketed expansion lists, which must all be of the same length in elements. | ||
When a progressive string that contains expansion lists is processed to expand its expansion lists, it is transformed into a comma-separated list, which is generated as follows: | When a progressive string that contains expansion lists is processed to expand its expansion lists, it is transformed into a comma-separated list, which is generated as follows: | ||
+ | |||
+ | For each integer ''n'' from 1 to ''L'', where ''L'' is the length in elements of each expansion list: | ||
+ | :If |
Revision as of 06:54, 10 February 2014
Each set of square brackets (‘[’ and ‘]’) contains a comma-separated list — an expansion list — of which each element can be:
- a plain string — e.g., “abc” or “123”;
- a range, expressed as two radix-10 integers, separated by a tilde — e.g., “1~5”; or
- a repetition, notated as a string and a radix-10 integer, separated by an asterisk — e.g., “a*3”.
Ranges can not only be from a lesser number to a greater number (e.g., “1~5”), but can also be backward — from a greater number to a lesser number (e.g., “5~1”).
= Range expansion
Each range x~y is expanded within its expansion list to a comma-separated list of radix-10 integers (which are plain strings), starting from the first endpoint x and ending at the second endpoint y.
If x < y, then the numbers in this list increase by increments of 1; if x > y, then the numbers in this list decrease by decrements of 1. E.g., “1~3” would become “1,2,3”, and “3~1” would become “3,2,1”.
If x = y, then this list has only one element, which is x. E.g., “2~2” would becomes “2”.
If either x or y are padded with leading zeros, then each number in the resultant list will be padded with leading zeros such that it is expressed in as many digits as the endpoint (either of x or y) that is padded with the most leading zeros. E.g., “07~11” would become “07,08,09,10,11”, and “003~1” would become “003,002,001”.
Square bracket expansion
A single progressive string value may contain multiple square-bracketed expansion lists, which must all be of the same length in elements.
When a progressive string that contains expansion lists is processed to expand its expansion lists, it is transformed into a comma-separated list, which is generated as follows:
For each integer n from 1 to L, where L is the length in elements of each expansion list:
- If