permutations for filters
Generates all permutations of the input list.
Signature
> permutations {flags}
Input/output types:
| input | output |
|---|---|
| list<any> | list<list<any>> |
| table | table |
Examples
Generate all permutations
> [1 2 3] | permutations
╭───┬───────────╮
│ 0 │ ╭───┬───╮ │
│ │ │ 0 │ 1 │ │
│ │ │ 1 │ 2 │ │
│ │ │ 2 │ 3 │ │
│ │ ╰───┴───╯ │
│ 1 │ ╭───┬───╮ │
│ │ │ 0 │ 2 │ │
│ │ │ 1 │ 1 │ │
│ │ │ 2 │ 3 │ │
│ │ ╰───┴───╯ │
│ 2 │ ╭───┬───╮ │
│ │ │ 0 │ 3 │ │
│ │ │ 1 │ 1 │ │
│ │ │ 2 │ 2 │ │
│ │ ╰───┴───╯ │
│ 3 │ ╭───┬───╮ │
│ │ │ 0 │ 1 │ │
│ │ │ 1 │ 3 │ │
│ │ │ 2 │ 2 │ │
│ │ ╰───┴───╯ │
│ 4 │ ╭───┬───╮ │
│ │ │ 0 │ 2 │ │
│ │ │ 1 │ 3 │ │
│ │ │ 2 │ 1 │ │
│ │ ╰───┴───╯ │
│ 5 │ ╭───┬───╮ │
│ │ │ 0 │ 3 │ │
│ │ │ 1 │ 2 │ │
│ │ │ 2 │ 1 │ │
│ │ ╰───┴───╯ │
╰───┴───────────╯Generate permutations of two elements
> [1 2] | permutations
╭───┬───────────╮
│ 0 │ ╭───┬───╮ │
│ │ │ 0 │ 1 │ │
│ │ │ 1 │ 2 │ │
│ │ ╰───┴───╯ │
│ 1 │ ╭───┬───╮ │
│ │ │ 0 │ 2 │ │
│ │ │ 1 │ 1 │ │
│ │ ╰───┴───╯ │
╰───┴───────────╯Empty list yields no permutations
> [] | permutations
╭────────────╮
│ empty list │
╰────────────╯