<~
Assign Or MergeMerges the right hand value to a variable on the left hand side (expression)
The Assign Or Merge operator merges your data from a the right hand side into the variable on the left hand side.
If the variable doesn’t exist, then it is created.
This operator is only available in expressions.
Lets say you have a directory hierarchy that looks like:
» tree
.
├── a
│ ├── )rPsD8Dt5EtaC4*Yyn0q
│ ├── B[E3P2@gyzl2oSfvFs5(
│ ├── WNYBb>B{Y:9oBNq~eVn{
│ ├── W~e5bLBkGkv 2sr<XTj:
│ └── lgCVRC.PkUkh(!epI(ls
├── b
│ ├── ]^[;og5$x'%Zp* TY(NR
│ ├── kKcuV<9@pBrFr@"O\j?%
│ ├── wX'\>V`4P=K}FaxE^Hra
│ ├── yXjB#Cu'{%iLtsDCkKU%
│ └── |oK7e25Dz7z&ys.?2(]E
├── c
│ ├── )Kb!TOQ]\9J6 &<Y\2qj
│ ├── -X-Dm,m[JU0FZ#b0+fe+
│ ├── Lw2"`S<ag{EnJ=YI8A\W
│ ├── W4RUF_D.z,%M|OFsLB_A
│ └── z@meR3m7h(~V4m7(V{N
├── d
│ ├── %"6Tn]&w@Uas*Gi5$?Q0
│ ├── F}Ly:]zGTk}4]V+L=Wk+
│ ├── z%;lf^2n0r'p0Fy?f[$j
│ ├── {Iz}*#HCR_@H.KyA3=xy
│ └── ~2hUs'_NftfpH`?>Bqpt
├── e
│ ├── :#'G'Rs~^~A)g,k29Er1
│ ├── =N-KR9!lh"H FjCp@sP%
│ └── ?,E XTt%TGD4vrvR@qXw
└── f
├── !B#v!iYSBmi<i6[mdlL'
├── _@$*?WgS0KozEnmHV*gW
├── eT8?OgIK@4zSHTz0$m<O
└── |c[c-8S.;X$&UzI@jp!X
7 directories, 27 files
…and in this example you want to list the files in only directories that are vowels, you can use the Assign Or Merge operator to append to the list on each iteration for foreach
:
» %[a,e] -> foreach d { files <~ g($d/*) }
» $files
[
"a/)rPsD8Dt5EtaC4*Yyn0q",
"a/B[E3P2@gyzl2oSfvFs5(",
"a/WNYBb\u003eB{Y:9oBNq~eVn{",
"a/W~e5bLBkGkv 2sr\u003cXTj:",
"a/lgCVRC.PkUkh(!epI(ls",
"e/:#'G'Rs~^~A)g,k29Er1",
"e/=N-KR9!lh\"H FjCp@sP%",
"e/?,E XTt%TGD4vrvR@qXw"
]
Please note that you can also do this with standard globbing, for example:
» files = g([ae]/*)
Assign Or Merge uses the same underlying algorithm as the alter -m
builtin.
alter
/ ~>
): Change a value within a structured data-type and pass that change along the pipeline without altering the original source inputexpr
): Expressions: mathematical, string comparisons, logical operatorsforeach
): Iterate through an arrayg
): Glob pattern matching for file system objects (eg *.txt
)%[]
Array Builder: Quickly generate arraysThis document was generated from gen/expr/assign-merge-op_doc.yaml.
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 Wed Sep 18 21:18:57 UTC 2024 against commit c037883c03788357164e9846c84d9f777251495d9452a8e.
Current version is 6.3.4225 (develop) which has been verified against tests cases.