github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/core/index/index_doc.yaml (about) 1 - DocumentID: item-index 2 Title: >+ 3 `[ Index ]` 4 CategoryID: parser 5 Summary: >- 6 Outputs an element from an array, map or table 7 Description: |- 8 Outputs an element or multiple elements from an array, map or table. 9 10 Please note that indexes in Murex are counted from zero. 11 Usage: |- 12 ``` 13 <stdin> -> [ element ] -> <stdout> 14 $variable[ element ] -> <stdout> 15 16 <stdin> -> ![ element ] -> <stdout> 17 ``` 18 Examples: |- 19 Return the 2nd (1), 4th (3) and 6th (5) element in an array: 20 21 ``` 22 » ja [0..9] -> [ 1 3 5 ] 23 [ 24 "1", 25 "3", 26 "5" 27 ] 28 ``` 29 30 Return the data-type and description of **config shell syntax-highlighting**: 31 32 ``` 33 » config -> [[ /shell/syntax-highlighting ]] -> [ Data-Type Description ] 34 [ 35 "bool", 36 "Syntax highlighting of murex code when in the interactive shell" 37 ] 38 ``` 39 40 Return all elements _except_ for 1 (2nd), 3 (4th) and 5 (6th): 41 42 ``` 43 » a [0..9]-> ![ 1 3 5 ] 44 0 45 2 46 4 47 6 48 7 49 8 50 9 51 ``` 52 53 Return all elements except for the data-type and description: 54 55 ``` 56 » config -> [[ /shell/syntax-highlighting ]] -> ![ Data-Type Description ] 57 { 58 "Default": true, 59 "Dynamic": false, 60 "Global": true, 61 "Value": true 62 } 63 ``` 64 65 Return the top 5 processes from `ps`, ordered by memory usage: 66 67 ``` 68 » ps aux -> [PID %MEM COMMAND] -> sort -nrk2 -> [..5] 69 915961 14.4 /home/lau/dev/go/bin/gopls 70 916184 4.4 /opt/visual-studio-code/code 71 108025 2.9 /usr/lib/firefox/firefox 72 1036 2.4 /usr/lib/baloo_file 73 915710 1.9 /opt/visual-studio-code/code 74 ``` 75 76 Return the 1st and 30th row: 77 78 ``` 79 » ps aux -> [*1 *30] 80 USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND 81 root 37 0.0 0.0 0 0 ? I< Dec18 0:00 [kworker/3:0H-events_highpri] 82 ``` 83 84 Return the 1st and 5th column: 85 86 ``` 87 » ps aux -> [*A *E] -> head -n5 88 USER VSZ 89 root 168284 90 root 0 91 root 0 92 root 0 93 ``` 94 Flags: 95 Detail: |- 96 ### Index counts from zero 97 98 Indexes in Murex behave like any other computer array in that all arrays 99 start from zero (`0`). 100 101 ### Include vs exclude 102 103 As demonstrated in the examples above, `[` specifies elements to include 104 where as `![` specifies elements to exclude. 105 106 ### Don't error upon missing elements 107 108 By default, **index** generates an error if an element doesn't exist. However 109 you can disable this behavior in `config` 110 111 ``` 112 » config -> [ foobar ] 113 Error in `[` ((builtin) 2,11): Key 'foobar' not found 114 115 » config set index silent true 116 117 » config -> [ foobar ] 118 ``` 119 Synonyms: 120 - "[" 121 - "![" 122 - item-index 123 - index 124 Related: 125 - range 126 - count 127 - a 128 - ja 129 - mtac 130 - element 131 - config