Difference between revisions of "Sequence"
(Character and spreadsheet sequences) |
|||
Line 29: | Line 29: | ||
[[Sequence]]( [[MakeDate]](2009,1,1), [[MakeDate]](2010,12,31), 4, dateUnit:"M" ) → | [[Sequence]]( [[MakeDate]](2009,1,1), [[MakeDate]](2010,12,31), 4, dateUnit:"M" ) → | ||
[ 1-Jan-2009, 1-May-2009, 1-Sep-2009, 1-Jan-2010, 1-May-2010, 1-Sep-2010 ] | [ 1-Jan-2009, 1-May-2009, 1-Sep-2009, 1-Jan-2010, 1-May-2010, 1-Sep-2010 ] | ||
+ | |||
+ | = Character Sequences = | ||
+ | |||
+ | ''New to Analytica 4.4 or patch release 4.3.3'' | ||
+ | |||
+ | The «start» and «stop» characters may be single characters. In this case, a sequence of characters following ascii order is returned. | ||
+ | |||
+ | :<code>[[Sequence]]('T','f')</code> → ['T','U','V','W','X','Y','Z','[','\',']','^','_','`','a','b','c','d','e','f'] | ||
+ | |||
+ | :<code>[[Sequence]]('!','@')</code> → ['!','""','#','$','%','&',''','(',')','*','+',',','-','.','/','0','1','2','3','4','5','6','7','8','9',':',';','<','=','>','?','@'] | ||
+ | |||
+ | = Spreadsheet Column Name Sequences = | ||
+ | |||
+ | ''New to Analytica 4.4 or patch 4.3.3'' | ||
+ | |||
+ | When «start» and «stop» are multi-letter sequences, containing only letters, with all letters having the same upper-case or lower-case, then a spreadsheet column sequence is returned. | ||
+ | |||
+ | These sequences are letter sequences that go from 'A'..'Z', then from 'AA'..'AZ', 'BA'..'BZ', ... 'ZA'..'ZZ', then 'AAA'..'ZZZ', 'AAAA'..'ZZZZ', etc., up to six digits total. | ||
+ | |||
+ | :<code>Sequence('W','AF')</code> → ['W','X','Y','Z','AA','AB','AC','AD','AE','AF'] | ||
+ | |||
+ | :For these sequences, the start and stop must consist entirely of letters, and all letters must be all upper case or all lower case. |
Revision as of 00:43, 30 April 2011
Sequence( Start, End, step )
Creates a list of numbers increasing or decreasing from Start to End by increments (or decrements) of Stepsize. Stepsize is optional and must be a positive number; if it is omitted, Analytica uses increments of 1. Start, End and Stepsize must be deterministic scalar numbers, not arrays.
Declaration
Examples
Strict sequences
Sequence expects the «step» to be positive (or omitted, in which case a step of 1 is assumed). A decreasing sequence is obtained by specifying a «start» less than «end». As a result of this convention, a sequence will always have at least one element.
(new to Analytica 4.2) There are cases where a strict sequence is desired, such that the sequence proceeds from «start» in increments of «step», according to the sign of «step». When «step» proceeds in the direction away from «end», then a zero-length sequence results. For example, in a For..Do loop, you may want zero iterations when «end» is less than «start». A strict sequence is obtained by specifying the optional parameter «strict» as true, e.g.
Sequence(x1,x2,strict:true)
When «strict» is specified as true, the «step» may be negative, and must be negative to obtain a decreasing sequence.
Date Sequences
new to Analytica 4.2
You can use Sequence to generate a sequence of dates between a given start and stop date, in increments such as months and years, by specifying the optional «dateUnit» parameter. Possible date units include: "Y" (years), "Q" (quarters), "M" (months), "WD" (weekdays), "D" (days), "h" (hours), "m" (minutes), "s" (seconds).
Sequence( MakeDate(2009,1,1), MakeDate(2010,12,31), 4, dateUnit:"M" ) → [ 1-Jan-2009, 1-May-2009, 1-Sep-2009, 1-Jan-2010, 1-May-2010, 1-Sep-2010 ]
Character Sequences
New to Analytica 4.4 or patch release 4.3.3
The «start» and «stop» characters may be single characters. In this case, a sequence of characters following ascii order is returned.
Sequence('T','f')
→ ['T','U','V','W','X','Y','Z','[','\',']','^','_','`','a','b','c','d','e','f']
Sequence('!','@')
→ ['!','""','#','$','%','&',,'(',')','*','+',',','-','.','/','0','1','2','3','4','5','6','7','8','9',':',';','<','=','>','?','@']
Spreadsheet Column Name Sequences
New to Analytica 4.4 or patch 4.3.3
When «start» and «stop» are multi-letter sequences, containing only letters, with all letters having the same upper-case or lower-case, then a spreadsheet column sequence is returned.
These sequences are letter sequences that go from 'A'..'Z', then from 'AA'..'AZ', 'BA'..'BZ', ... 'ZA'..'ZZ', then 'AAA'..'ZZZ', 'AAAA'..'ZZZZ', etc., up to six digits total.
Sequence('W','AF')
→ ['W','X','Y','Z','AA','AB','AC','AD','AE','AF']
- For these sequences, the start and stop must consist entirely of letters, and all letters must be all upper case or all lower case.
Enable comment auto-refresher