github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/core/mkarray/ranges_doc.yaml (about)

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