rfc:array_part
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:array_part [2012/05/14 10:35] – [Specification for the function] cataphract | rfc:array_part [2012/05/14 11:05] – [Specification for the function] cataphract | ||
---|---|---|---|
Line 25: | Line 25: | ||
Each part specification shall have one of the following forms: | Each part specification shall have one of the following forms: | ||
- | * An sequentially indexed | + | * A sequential |
* A single index, which specifies that only the element existing at that index will be kept. In this case the level will be collapsed onto the previous one, meaning all the arrays at that level will be replaced with its element the specified index. | * A single index, which specifies that only the element existing at that index will be kept. In this case the level will be collapsed onto the previous one, meaning all the arrays at that level will be replaced with its element the specified index. | ||
- | * A span part specification is an associative array. The following keys are allowed //start//, //end// and //step//. At least //start// or //end// must be specified. //start// and //end// are an index or a special value -- '' | + | * A span part specification is an associative array. The following keys are allowed //start//, //end// and //step//. At least //start// or //end// must be specified. //start// and //end// are an index or a special value -- '' |
Span parts extract any number of elements (possibly 0) starting at the index specified by //start// and advancing until //end// is reached, advancing in steps of //step//. The element at the index specified at //end// is included. | Span parts extract any number of elements (possibly 0) starting at the index specified by //start// and advancing until //end// is reached, advancing in steps of //step//. The element at the index specified at //end// is included. | ||
Line 34: | Line 34: | ||
An index //i// has the following meaning: | An index //i// has the following meaning: | ||
* If '' | * If '' | ||
- | * If '' | + | * If '' |
* If '' | * If '' | ||
+ | |||
+ | The keys in the original array are not preserved in the output, expect at levels that were not visited. | ||
This function shall return '' | This function shall return '' | ||
Line 42: | Line 44: | ||
* Giving malformed part specifications (where the individual elements do not follow the syntactic rules given here). | * Giving malformed part specifications (where the individual elements do not follow the syntactic rules given here). | ||
* Specifying an part index than does not exist at at least of the elements at the level the part refers to: (e.g. '' | * Specifying an part index than does not exist at at least of the elements at the level the part refers to: (e.g. '' | ||
- | * Giving a part specification with levels that do not exist in the input. This does not apply if, as a result of a span part that comprises all the elements of that level and at the level before | + | * Giving a part specification with levels that do not exist in the input. This does not apply if, as a result of a span part that comprises all the elements of that level and at the level before |
* Encountering already visited array elements from the original array (recursion). | * Encountering already visited array elements from the original array (recursion). | ||
rfc/array_part.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1