A sophisticated yet simple way to build an array or list
Pronounced "make array", like
mkdir (etc), murex has a pretty sophisticated builtin for generating arrays. Think like bash's
a: [start..end] -> <stdout> a: [start..end.base] -> <stdout> a: [start..end,start..end] -> <stdout> a: [start..end][start..end] -> <stdout>
All usages also work with
ta as well:
ja: [start..end] -> <stdout> ta: data-type [start..end] -> <stdout>
» a: [1..3] 1 2 3 » a: [3..1] 3 2 1 » a: [01..03] 01 02 03
You can also specify an alternative number base by using an
. 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:
Also note that the additional zeros denotes padding (ie the results will start at
01, etc rather than
You can select 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.
Unlike bash, murex also supports some special ranges:
» a: [mon..sun] » a: [monday..sunday] » a: [jan..dec] » a: [january..december] » a: [spring..winter]
It is also 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:
» a: [Monday..Sunday] Monday Tuesday Wednesday Thursday Friday Saturday Sunday
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 just 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)
The syntax for
a is a comma separated list of parameters with expansions stored in square brackets. You can have an expansion embedded inside a parameter or as it's own parameter. Expansions can also have multiple parameters.
» a: 01,02,03,05,06,07 01 02 03 05 06 07 » a: 0[1..3],0[5..7] 01 02 03 05 06 07 » a: 0[1..3,5..7] 01 02 03 05 06 07 » a: b[o,i]b bob bib
You can also have multiple expansion blocks in a single parameter:
» a: a[1..3]b[5..7] a1b5 a1b6 a1b7 a2b5 a2b6 a2b7 a3b5 a3b6 a3b7
a will cycle through each iteration of the last expansion, moving itself backwards through the string; behaving like an normal counter.
As you can see from the previous examples,
a returns the array as a list of strings. This is so you can stream excessively long arrays, for example every IPv4 address:
a: [0..254].[0..254].[0..254].[0..254] (this kind of array expansion would hang bash).
However if you needed a JSON string then you can use all the same syntax as
a but forgo the streaming capability:
» ja: [Monday..Sunday] [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ]
This is particularly useful if you are adding formating that might break under
a's formatting (which uses the
str data type).
@[(range): Outputs a ranged subset of data from STDIN
[[(element): Outputs an element from a nested structure
[(index): Outputs an element from an array, map or table
ja: A sophisticated yet simply way to build a JSON array
len: Outputs the length of an array
mtac: Reverse the order of an array
str(string): string (primitive)
ta: A sophisticated yet simple way to build an array of a user defined data-type
This site's content is rebuilt automatically from murex's source code after each merge to the
master branch. Downloadable murex binaries are also built with the website.
Last built on Fri Sep 10 15:05:25 UTC 2021 against commit 437c274437c274fded54d82e99d70ea7d2917f332c095dd.
Current version is 2.2.1200 BETA which has been verified against tests.