[[
(element)Outputs an element from a nested structure
Outputs an element from an array, map or table. Unlike index ([
), element takes a path parameter which means it can work inside nested structures without pipelining multiple commands together. However this comes with the drawback that you can only return one element.
Element ([[
) also doesn’t support the bang prefix (unlike) index.
Please note that indexes in murex are counted from zero.
<stdin> -> [[ element ]] -> <stdout>
$variable[[ element ]] -> <stdout>
Return the 2nd element in an array
» ja [0..9] -> [[ /1 ]]
[
"1",
]
Return the data-type and description of config shell syntax-highlighting
» config -> [[ /shell/syntax-highlighting/Data-Type ]]
bool
Indexes in murex behave like any other computer array in that all arrays start from zero (0
).
Element uses the first character in the path as the separator. So the following are all valid parameters:
» config -> [[ ,shell,syntax-highlighting,Data-Type ]]
bool
» config -> [[ >shell>syntax-highlighting>Data-Type ]]
bool
» config -> [[ \|shell\|syntax-highlighting\|Data-Type ]]
bool
» config -> [[ >shell>syntax-highlighting>Data-Type ]]
bool
However there are a few of caveats:
|
, ;
, }
, etc) will need to be escaped. For readability reasons it is recommended not to use such characters even though it is technically possible to.
# Would fail because the semi-colon is an unescaped / unquoted shell token
config -> [[ ;shell-syntax-highlighting;Data-Type ]]
# Would fail because 'syntax-highlighting' and 'Data-Type' both also contain
# the separator character
config -> [[ -shell-syntax-highlighting-Data-Type ]]
# Would fail because you cannot escape key names (escaping happens at the
# shell parser level rather than command parameter level)
config -> [[ -shell-syntax\-highlighting-Data\-Type ]]
In murex, everything is a function. Thus even [[
is a function name and the closing ]]
is actually a last parameter. This means the recommended way to quote element parameters is to quote specific key names or the entire path:
» config -> [[ /shell/"syntax-highlighting"/Data-Type ]]
bool
» config -> [[ "|shell|syntax-highlighting|Data-Type" ]]
bool
[[
element
[
(index): Outputs an element from an array, map or table[
(range): Outputs a ranged subset of data from STDINa
(mkarray): A sophisticated yet simple way to build an array or listconfig
: Query or define murex runtime settingscount
: Count items in a map, list or arrayja
(mkarray): A sophisticated yet simply way to build a JSON arraymtac
: Reverse the order of an arrayThis 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 Mon Feb 13 09:18:06 UTC 2023 against commit f339958f33995895c1d997efcdbb8408d2c8d45f8b5f934.
Current version is which has been verified against 13950 tests cases.