github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/core/mkarray/array_doc.yaml (about) 1 - DocumentID: a 2 Title: >+ 3 `a` (mkarray) 4 CategoryID: commands 5 Summary: >- 6 A sophisticated yet simple way to build an array or list 7 Description: |- 8 Pronounced "make array", like `mkdir` (etc), Murex has a pretty sophisticated 9 builtin for generating arrays. Think like bash's `{1..9}` syntax: 10 11 ``` 12 a [1..9] 13 ``` 14 15 Except Murex also supports other sets of ranges like dates, days of the week, 16 and alternative number bases. 17 Usage: |- 18 {{ include "gen/includes/mkarray-range-usage.inc.md" }} 19 Examples: |- 20 ``` 21 » a [1..3] 22 1 23 2 24 3 25 26 » a [3..1] 27 3 28 2 29 1 30 31 » a [01..03] 32 01 33 02 34 03 35 ``` 36 Flags: 37 Detail: |- 38 ### Advanced Array Syntax 39 40 The syntax for `a` is a comma separated list of parameters with expansions 41 stored in square brackets. You can have an expansion embedded inside a 42 parameter or as it's own parameter. Expansions can also have multiple 43 parameters. 44 45 ``` 46 » a 01,02,03,05,06,07 47 01 48 02 49 03 50 05 51 06 52 07 53 ``` 54 55 ``` 56 » a 0[1..3],0[5..7] 57 01 58 02 59 03 60 05 61 06 62 07 63 ``` 64 65 ``` 66 » a 0[1..3,5..7] 67 01 68 02 69 03 70 05 71 06 72 07 73 ``` 74 75 ``` 76 » a b[o,i]b 77 bob 78 bib 79 ``` 80 81 You can also have multiple expansion blocks in a single parameter: 82 83 ``` 84 » a a[1..3]b[5..7] 85 a1b5 86 a1b6 87 a1b7 88 a2b5 89 a2b6 90 a2b7 91 a3b5 92 a3b6 93 a3b7 94 ``` 95 96 `a` will cycle through each iteration of the last expansion, moving itself 97 backwards through the string; behaving like an normal counter. 98 99 ### Creating JSON arrays with `ja` 100 101 As you can see from the previous examples, `a` returns the array as a 102 list of strings. This is so you can stream excessively long arrays, for 103 example every IPv4 address: `a: [0..254].[0..254].[0..254].[0..254]` 104 (this kind of array expansion would hang bash). 105 106 However if you needed a JSON string then you can use all the same syntax 107 as `a` but forgo the streaming capability: 108 109 ``` 110 » ja [Monday..Sunday] 111 [ 112 "Monday", 113 "Tuesday", 114 "Wednesday", 115 "Thursday", 116 "Friday", 117 "Saturday", 118 "Sunday" 119 ] 120 ``` 121 122 This is particularly useful if you are adding formatting that might break 123 under `a`'s formatting (which uses the `str` data type). 124 125 ### Smart arrays 126 127 Murex supports a number of different formats that can be used to generate 128 arrays. For more details on these please refer to the documents for each format 129 130 {{ include "gen/includes/autogenerated.mkarray.inc.md" }} 131 Synonyms: 132 Related: 133 - create-array 134 - range 135 - count 136 - item-index 137 - element 138 - mtac 139 - ja 140 - ta 141 - str 142 143 - DocumentID: ja 144 Title: >+ 145 `ja` (mkarray) 146 CategoryID: commands 147 Summary: >- 148 A sophisticated yet simply way to build a JSON array 149 Description: |- 150 Murex has a pretty sophisticated builtin for generating JSON arrays. 151 It works a little bit like Bash's `{1..9}` syntax but includes a few 152 additional nifty features. 153 154 **Please note that while this builtin is not marked for deprecation, it has 155 been superseded by the `%[]` tokens.** ([read more](../parser/create-array.md)) 156 Usage: |- 157 ``` 158 ja [start..end] -> <stdout> 159 ja [start..end.base] -> <stdout> 160 ja [start..end,start..end] -> <stdout> 161 ja [start..end][start..end] -> <stdout> 162 ``` 163 Examples: |- 164 ``` 165 » ja [1..5] 166 [ 167 "1", 168 "2", 169 "3", 170 "4", 171 "5" 172 ] 173 ``` 174 175 ``` 176 » ja [Monday..Sunday] 177 [ 178 "Monday", 179 "Tuesday", 180 "Wednesday", 181 "Thursday", 182 "Friday", 183 "Saturday", 184 "Sunday" 185 ] 186 ``` 187 188 Please note that as per the first example, all arrays generated by `ja` are 189 arrays of strings - even if you're command is ranging over integers. 190 Flags: 191 Detail: |- 192 Please read the documentation on `a` for a more detailed breakdown on of 193 `ja`'s supported features. 194 Synonyms: 195 Related: 196 - create-array 197 - range 198 - count 199 - item-index 200 - element 201 - mtac 202 - a 203 - ta 204 - json 205 206 - DocumentID: ta 207 Title: >+ 208 `ta` (mkarray) 209 CategoryID: commands 210 Summary: >- 211 A sophisticated yet simple way to build an array of a user defined data-type 212 Description: |- 213 Murex has a pretty sophisticated builtin for generating arrays. It works 214 a little bit like Bash's `{1..9}` syntax but includes a few additional nifty 215 features and the output format is user defined. 216 Usage: |- 217 ``` 218 ta data-type [start..end] -> <stdout> 219 ta data-type [start..end.base] -> <stdout> 220 ta data-type [start..end,start..end] -> <stdout> 221 ta data-type [start..end][start..end] -> <stdout> 222 ``` 223 Examples: |- 224 ``` 225 » ta json [1..5] 226 [ 227 "1", 228 "2", 229 "3", 230 "4", 231 "5" 232 ] 233 ``` 234 235 ``` 236 » ta json [Monday..Sunday] 237 [ 238 "Monday", 239 "Tuesday", 240 "Wednesday", 241 "Thursday", 242 "Friday", 243 "Saturday", 244 "Sunday" 245 ] 246 ``` 247 248 Please note that as per the first example, all arrays generated by `ta` are 249 arrays of strings - even if you're command is ranging over integers. Also 250 if you are only creating arrays in JSON then you could use `ja` instead. 251 Flags: 252 Detail: |- 253 Please read the documentation on `a` for a more detailed breakdown on of 254 `ta`'s supported features. 255 Synonyms: 256 Related: 257 - create-array 258 - range 259 - count 260 - item-index 261 - element 262 - mtac 263 - a 264 - ja