-
Notifications
You must be signed in to change notification settings - Fork 29
/
ranges_doc.yaml
530 lines (457 loc) · 9.11 KB
/
ranges_doc.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
- DocumentID: decimal
Title: >+
Decimal Ranges
CategoryID: mkarray
Summary: >-
Create arrays of decimal integers
Description: |-
This document describes how to create arrays of decimals using mkarray (`a` et
al).
{{ include "gen/includes/mkarray-range-description.inc.md" }}
Usage: |-
{{ include "gen/includes/mkarray-range-usage.inc.md" }}
Examples: |-
```
» a [1..3]
1
2
3
```
```
» a [3..1]
3
2
1
```
```
» a [01..03]
01
02
03
```
Flags:
Detail: |-
### Floating Point Numbers
If you do need a range of fixed floating point numbers generated then you can
do so by merging two decimal integer ranges together. For example
```
» a [0..5].[0..9]
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
...
4.8
4.9
5.0
5.1
5.2
5.3
5.4
5.5
5.6
5.7
5.8
5.9
```
### Everything Is A String
Please note that all arrays are created as strings. Even when using typed
arrays such as JSON (`ja`).
```
» ja [0..5]
[
"0",
"1",
"2",
"3",
"4",
"5"
]
```
Synonyms:
Related:
- non-decimal
- character
- a
- ja
- ta
- range
- count
- index
- element
- DocumentID: non-decimal
Title: >+
Non-Decimal Ranges
CategoryID: mkarray
Summary: >-
Create arrays of integers from non-decimal number bases
Description: |-
When making arrays you can specify ranges of an alternative number base by
using an `x` or `.` in the end range:
```
a [00..ffx16]
a [00..ff.16]
```
All number bases from 2 (binary) to 36 (0-9 plus a-z) are supported.
Please note that the start and end range are written in the target base
while the base identifier is written in decimal: `[hex..hex.dec]`
Also note that the additional zeros denotes padding (ie the results will
start at `00`, `01`, etc rather than `0`, `1`...)
{{ include "gen/includes/mkarray-range-description.inc.md" }}
Usage: |-
{{ include "gen/includes/mkarray-range-usage.inc.md" }}
Examples: |-
```
» a [08..10x16]
08
09
0a
0b
0c
0d
0e
0f
10
```
```
» a [10..08x16]
10
f
e
d
c
b
a
9
8
```
Flags:
Detail: |-
### Floating Point Numbers
If you do need a range of fixed floating point numbers generated then you can
do so by merging two decimal integer ranges together. For example
```
» a [05..10x8].[0..7]
05.0
05.1
05.2
05.3
05.4
05.5
05.6
05.7
06.0
06.1
06.2
...
07.5
07.6
07.7
10.0
10.1
10.2
10.3
10.4
10.5
10.6
10.7
```
### Everything Is A String
Please note that all arrays are created as strings. Even when using typed
arrays such as JSON (`ja`).
```
» ja [0..5]
[
"0",
"1",
"2",
"3",
"4",
"5"
]
```
Synonyms:
Related:
- decimal
- character
- a
- ja
- ta
- range
- count
- index
- element
- DocumentID: character
Title: >+
Character arrays
CategoryID: mkarray
Summary: >-
Making character arrays (a to z)
Description: |-
You can create arrays from a range of letters (a to z):
```
» a [a..z]
» a [z..a]
» a [A..Z]
» a [Z..A]
```
...or any characters within that range.
{{ include "gen/includes/mkarray-range-description.inc.md" }}
Usage: |-
{{ include "gen/includes/mkarray-range-usage.inc.md" }}
Examples: |-
```
» a [a..c]
a
b
c
```
```
» a [c..a]
c
b
a
```
Flags:
Detail:
Synonyms:
Related:
- decimal
- non-decimal
- a
- ja
- ta
- range
- count
- index
- element
- DocumentID: special
Title: >+
Special Ranges
CategoryID: mkarray
Summary: >-
Create arrays from ranges of dictionary terms (eg weekdays, months, seasons, etc)
Description: |-
Unlike bash, Murex also supports some special ranges:
```
» a [mon..sun]
» a [monday..sunday]
» a [jan..dec]
» a [january..december]
» a [spring..winter]
```
{{ include "gen/includes/mkarray-range-description.inc.md" }}
Usage: |-
{{ include "gen/includes/mkarray-range-usage.inc.md" }}
Examples: |-
```
» a [summer..winter]
summer
autumn
winter
```
Flags:
Detail: |-
### Case Sensitivity
Special ranges are case aware. If the ranges are uppercase then the return will
be uppercase. If the ranges are title case (capital first letter) then the
return will be in title case.
#### lower case
```
» a [monday..wednesday]
monday
tuesday
wednesday
```
#### Title Case
```
» a [Monday..Wednesday]
Monday
Tuesday
Wednesday
```
#### UPPER CASE
```
» a [MONDAY..WEDNESDAY]
MONDAY
TUESDAY
WEDNESDAY
```
### Looping vs Negative Ranges
Where the special ranges differ from a regular range is they cannot
cannot down. eg `a: [3..1]` would output
```
» a [3..1]
3
2
1
```
however a negative range in special ranges will cycle through to the end
of the range and then loop back from the start:
```
» a [Thursday..Wednesday]
Thursday
Friday
Saturday
Sunday
Monday
Tuesday
Wednesday
```
This decision was made because generally with ranges of this type, you
would more often prefer to cycle through values rather than iterate
backwards through the list.
If you did want to reverse then pipe the output into another tool:
```
» a [Monday..Friday] -> mtac
Friday
Thursday
Wednesday
Tuesday
Monday
```
There are other UNIX tools which aren't data type aware but would work in
this specific scenario:
* `tac` (Linux),
* `tail -r` (BSD / OS X)
* `perl -e "print reverse <>"` (Multi-platform but requires Perl installed)
### Supported Dictionary Terms
Below is the source for the supported dictionary terms:
```go
{{ include "builtins/core/mkarray/consts.go" }}
```
Synonyms:
Related:
- date
- a
- ja
- ta
- datetime
- mtac
- range
- count
- index
- element
- DocumentID: date
Title: >+
Calendar Date Ranges
CategoryID: mkarray
Summary: >-
Create arrays of dates
Description: |-
Unlike bash, Murex also supports date ranges:
```
» a [25-dec-2020..05-jan-2021]
» a [..25-dec-2020]
» a [25-dec-2020..]
```
{{ include "gen/includes/mkarray-range-description.inc.md" }}
Usage: |-
{{ include "gen/includes/mkarray-range-usage.inc.md" }}
Examples: |-
```
» a [25-Dec-2020..01-Jan-2021]
25-Dec-2020
26-Dec-2020
27-Dec-2020
28-Dec-2020
29-Dec-2020
30-Dec-2020
31-Dec-2020
01-Jan-2021
```
```
» a [31-Dec..25-Dec]
31-Dec
30-Dec
29-Dec
28-Dec
27-Dec
26-Dec
25-Dec
```
Flags:
Detail: |-
### Current Date
If the start value is missing (eg `[..01-Jan-2020]`) then mkarray (`a` et al)
will start the range from the current date and count up or down to the end.
If the end value is missing (eg `[01-Jan-2020..]`) then mkarray will start at
the start value, as usual, and count up or down to the current date.
For example, if today was 25th December 2020:
```
» a [23-December-2020..]
23-December-2020
24-December-2020
25-December-2020
```
```
» a [..23-December-2020]
25-December-2020
24-December-2020
23-December-2020
```
This can lead so some fun like countdowns:
```
» out "${a: [..01-January-2021] -> len -> =-1} days until the new year!"
7 days until the new year!
```
### Case Sensitivity
Date ranges are case aware. If the ranges are uppercase then the return will be
uppercase. If the ranges are title case (capital first letter) then the return
will be in title case.
#### lower case
```
» a [01-jan..03-jan]
01-jan
02-jan
03-jan
```
#### Title Case
```
» a [01-Jan..03-Jan]
01-Jan
02-Jan
03-Jan
```
#### UPPER CASE
```
» a [01-JAN..03-JAN]
01-JAN
02-JAN
03-JAN
```
### Supported Date Formatting
Below is the source for the supported formatting options for date ranges:
```go
{{ include "builtins/core/mkarray/date.go" }}
```
If you do need any other formatting options not supported there, you can use
`datetime` to convert the output of `a`. eg:
```
» a [01-Jan-2020..03-Jan-2020] -> foreach { -> datetime --in "{go}02-Jan-2006" --out "{py}%A, %d %B"; echo }
Wednesday, 01 January
Thursday, 02 January
Friday, 03 January
```
Synonyms:
Related:
- special
- a
- ja
- ta
- datetime
- mtac
- range
- count
- index
- element