github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/commands/mtac.md (about)

     1  # `mtac`
     2  
     3  > Reverse the order of an array
     4  
     5  ## Description
     6  
     7  `mtac` takes input from STDIN and reverses the order of it.
     8  
     9  It's name is derived from a program called `tac` - a tool that functions
    10  like `cat` but returns the contents in the reverse order. The difference
    11  with the `mtac` builtin is that it is data-type aware. So it doesn't just
    12  function as a replacement for `tac` but it also works on JSON arrays,
    13  s-expressions, and any other data-type supporting arrays compiled into
    14  Murex.
    15  
    16  ## Usage
    17  
    18  ```
    19  <stdin> -> mtac -> <stdout>
    20  ```
    21  
    22  ## Examples
    23  
    24  ```
    25  » ja [Monday..Friday] -> mtac
    26  [
    27      "Friday",
    28      "Thursday",
    29      "Wednesday",
    30      "Tuesday",
    31      "Monday"
    32  ]
    33  
    34  # Normal output (without mtac)
    35  » ja [Monday..Friday]
    36  [
    37      "Monday",
    38      "Tuesday",
    39      "Wednesday",
    40      "Thursday",
    41      "Friday"
    42  ]
    43  ```
    44  
    45  ## Detail
    46  
    47  Please bare in mind that while Murex is optimised with concurrency and
    48  streaming in mind, it's impossible to reverse an incomplete array. Thus all
    49  all of STDIN must have been read and that file closed before `mtac` can
    50  output.
    51  
    52  In practical terms you shouldn't notice any difference except for when
    53  STDIN is a long running process or non-standard stream (eg network pipe).
    54  
    55  ## Synonyms
    56  
    57  * `mtac`
    58  * `list.reverse`
    59  
    60  
    61  ## See Also
    62  
    63  * [`2darray` ](../commands/2darray.md):
    64    Create a 2D JSON array from multiple input sources
    65  * [`a` (mkarray)](../commands/a.md):
    66    A sophisticated yet simple way to build an array or list
    67  * [`append`](../commands/append.md):
    68    Add data to the end of an array
    69  * [`count`](../commands/count.md):
    70    Count items in a map, list or array
    71  * [`ja` (mkarray)](../commands/ja.md):
    72    A sophisticated yet simply way to build a JSON array
    73  * [`jsplit` ](../commands/jsplit.md):
    74    Splits STDIN into a JSON array based on a regex parameter
    75  * [`map`](../commands/map.md):
    76    Creates a map from two data sources
    77  * [`msort`](../commands/msort.md):
    78    Sorts an array - data type agnostic
    79  * [`prefix`](../commands/prefix.md):
    80    Prefix a string to every item in a list
    81  * [`prepend`](../commands/prepend.md):
    82    Add data to the start of an array
    83  * [`pretty`](../commands/pretty.md):
    84    Prettifies JSON to make it human readable
    85  * [`suffix`](../commands/suffix.md):
    86    Prefix a string to every item in a list
    87  * [`ta` (mkarray)](../commands/ta.md):
    88    A sophisticated yet simple way to build an array of a user defined data-type
    89  
    90  <hr/>
    91  
    92  This document was generated from [builtins/core/lists/mtac_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/core/lists/mtac_doc.yaml).