[Question]
  [
Interval notation is a way to write complicated range bounds more conveniently and concisely than writing an inequality. The challenge, should you choose to accept it, is to write a program or function that interprets a subset of interval notation. In this subset, intervals are a comma-separated pair of integers delimited by either brackets, parentheses, or both.
The range starts from the first integer ends at the second integer, inclusive if delimited by a bracket or exclusive if by parentheses. Multiple ranges, delimited by `U`, may be chained together, in which case duplicate elements are removed.
Input is a string in interval notation and output is a list of numbers contained in the specified interval. Only meaningful intervals are valid, so ranges may overlap, but the start will always be less than the end. Zero sized intervals should have an empty output. All integers in the interval must be displayed once and only once, but may be outputted in any particular order.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so the lowest byte count wins.
## Other Details
* Invalid inputs are undefined behavior
* a `∪` or `⋃` symbol may be used instead of `U`
* The `U` will always be between ranges, never in front or behind
* If your language uses a character other than `-` to represent negative numbers that may be used instead
## Test Cases
```
[0,5] -> [0,1,2,3,4,5]
(0,5] -> [1,2,3,4,5]
[0,5) -> [0,1,2,3,4]
(0,5) -> [1,2,3,4]
[9,13] -> [9,10,11,12,13]
[-5,-1] -> [-5,-4,-3,-2,-1]
[-5,-1) -> [-5,-4,-3,-2]
(-5,-1] -> [-4,-3,-2,-1]
(-5,-1) -> [-4,-3,-2]
[-3,2] -> [-3,-2,-1,0,1,2]
[-3,2) -> [-3,-2,-1,0,1]
(-3,2] -> [-2,-1,0,1,2]
(-3,2) -> [-2,-1,0,1]
[0,0] -> [0]
(0,0] -> []
[0,0) -> []
(0,0) -> []
[1,2) -> [1]
(1,2) -> []
[-3,0)U(0,3] -> [-3,-2,-1,1,2,3]
[-3,0)U[0,3] -> [-3,-2,-1,0,1,2,3]
[-3,0]U[0,3] -> [-3,-2,-1,0,1,2,3]
[-3,0]U[2,5] -> [-3,-2,-1,0,2,3,4,5]
[1,5]U[2,4] -> [1,2,3,4,5]
[-5,-1]U[-6,-2] -> [-5,-4,-3,-2,-1,-6]
[-5,-1]U[-6,0] -> [-6,-5,-4,-3,-2,-1,0]
[-5,-1]U[-6,-2]U[-7,0] -> [-7,-6,-5,-4,-3,-2,-1,0]
[1,2)U[2,3)U[3,4)U[4,5) -> [1,2,3,4]
[2,1) -> Undefined
U(5,10) -> Undefined
[13,18)U -> Undefined
```
  
[Answer]
# [Python 3](https://docs.python.org/3/), 79 bytes
```
lambda s:eval('{*range%s}'%s.translate({91:40,40:'(1+',93:'+1)',85:',*range'}))
```
[Try it online!](https://tio.run/##jZLRboMgFIav61MQkwZY0YjaZjXp3qJXrhd04mZirRG2rDE@uwNhlra72A0e/v/7Fc6xvciPc5OM5e51rNnpWDAgMv7FagT7p44173wpBrgUoVQbUTPJUb@lWRqRNMogoitItkkGVxRD8rzOIDEhOGA8Vqf23EkgLsLzynMH6qrhoGq0EApZVE3YcVYgHIq2rqR2BcKZt2AEHMFuwo2FfBC8AB97i7arGolKv2cD6Lj87BpegL5EDA8A8e@Wv0ktHAfs4zGPyPqgk6qgJCYJSZXgoVl2RM3iW9aQ2CUVtyU0MWlVKZYSGmvJy4M1CaixdJmSICFBrDXr4XtPfcENuQnkJmY8V8/Y0hYl03mthR8s/aZrxg0gJ3Cl1fUj27Pp/nZjDGxr5NS6NbZHypg35kAR3is2uTvx1MwZyB@B6AY5/AuJf4fqINfpUrVqJn0cvJnAPg82usV/jI8EG3tN/YZErSqq1vT@5/gB "Python 3 – Try It Online")
-6 bytes thanks to ovs  
-3 bytes thanks to dingledooper
[Answer]
# [C++ (gcc)](https://gcc.gnu.org/), ~~139~~ ~~138~~ ~~134~~ ~~104~~ ~~101~~ 100 bytes
Uses C++20 features which aren't enabled by default in GCC, but are standard.
```
int f(auto&s,auto&o){int x,y;for(char c,d;s>>c>>x>>d>>y>>d;s>>d)for(y-=d<42;y>x-c%2;o.insert(y--));}
```
[Try it online!](https://tio.run/##lZXRrqIwEIbveYqGzXpoLB5A3ZMV7c0@w7lSsyGluiRKCRSjMbz6ulMKUkRPsl4UOvP90@mUjizL3D1jt1uSSrRzolKKUUHqh8BXZTyTS7gTucP@RDliJA4LShmlZ0pjSi8wKkOMFXJxV/FyFoQXenbZ9yAUkyQteC7B4WIcVrdvScoOZczRMhGFzHl0pFZnK4amE2dS5D2IS2q9v6MIFZLnXMhLlrDogMSJ50wcswPMJI/Rr/EYSV5IBAILApdM1vM4khG6Wgh@TKTKL@PFAoAk3aMkzUoZvnDycwbZ8Di0qhAiRjJhDXWPq16K9Rat9ApXe@2R@dYmyPaITwIyJTMyJ3ZFtNdpvU98Son7yp4Om7pO9ZP40zokvIDSJ34AFgNw58T1a0K9zYg7JW4ApkcEPyLd6kaIZ3rH0A/Ea5gHWtsK9Qb7BB4QRvh7hGdyp5MPtVBUrzkOs5ja1qNwz@IMLGu/WcXMrLX19uLhT5BP@3vWB/fIrQec95Tc/g8ZNN@YQQ4/Nh8ghc5efo760D/X7g8IowPC25efkKa9F7D3Mjg8P1rZB/laqUquEp/CCCnDOBvcDXVf2wt7EklcX1Pn4eqO1Igt3Rnqa89EKdFyid7sN/VQ/kndINTM3tiLe0dYoI1t35nW2mAE5bwoD7KGwi58otuK7nlIP67dIpWBih4KaYH/agLQ45bQq2mz1G@Ya@/O0SJieHDjEjlqiqDaPRppAi1MtOmU6qeXVZtqQFUa8qaDVcOyaX4C6zu4KcUmhQJUlqX@Vo5RkjptvQe5qDTqZmpmUB9bmz6c6u0v2x2ifXFzYeEVG4@D6B8 "C++ (gcc) – Try It Online")
Uses streams because I wanted to simulate`>>`a`>>`merge`>>`conflict instead of writing top `%p`ercentage `printf`/`scanf` calls.
The input is an EOF terminated stream (I could adapt this to accept `'\n'` termination, though). It doesn't actually check the separator.
The output is stored into a `std::set<int>` reference. It must be empty when called.
Usage:
```
std::istringstream input{str};
std::set<int> output;
f(input, output);
// Output now contains the result
```
Ungolfed:
```
#include <set> // std::set
#include <iostream> // streams (abstracted with abbreviated templates)
// input: An EOF terminated std::basic_istream (e.g. std::istringstream)
// output: stored into a reference to a std::set<int>. Must be empty.
// Golfed code returns int, but doesn't actually return anything
void interpret_interval(std::basic_istream &input, std::set<int> &output)
{
    // Holders for our range
    int start, end;
    // read input
    for (char left, right, tmp /* overwrites left/right in golfed code */;
         // this will return false on EOF (or EOS)
         //       [       -1       ,      4      )
         input >> left >> start >> tmp >> end >> right;
         // discard U, sets EOF bit on end
         input >> tmp)
    {
         // done indirectly in the golfed code
         if (left == '[') // golf check: '(' == 40, '[' == 91, do a modulo 2
             start--; // one extra iteration 
         if (right == ')') // golf check: ')' == 41, ']' == 93, less than 42
             end--; // one less iteration
         // Loop from end to start, inserting all the numbers in the
         // range to output.
         // XXX: std::iota? Doubt it would be smaller due to the include.
         for (; end > start; end--) {
             output.insert(end);
         }
    }
    // output now contains the set of values. Due to it being a std::set, all values
    // are unique. :)
}
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~23~~ 22 bytes
```
ṣ”Uµṙ1“(Ḋ)Ṗ,r”yḟØ[V)FQ
```
[Try it online!](https://tio.run/##jZKxasMwEIb3PEVGCU5gSU6gS8fuGRwoImOXkqlbttCl0DFDSSGlkKyZSgs23Rr6IPKLqHeWal/sDl1Op/u/X5bufHuzXK5C8NWhXr8UXx@@etb1eid8@Sh99QR3WF758vW0dXN5NQv@892Xb/X90Zd7jKcHDN8bX21xvQ7BZTBZjNXlGBMNBizkWBiJtsyKxMpzNpKSk8hdgLbRjRmyGrSh0sipCSgdJUpzUBaUoVrSZF/DL3ATdwjuaHGHq0l0QqG5b5LkQKKTOg83CGboaHx@lnrWvD9toiBTLlhOrUk9QqHdxAtlskDW9m7cNLMF3BDIzpDFvxDzO1SGdNPVGInJh4OPEyicmlKL/xgfqGl6Jp1gMaIVY97/OX4A "Jelly – Try It Online")
-1 byte [thanks to](https://codegolf.stackexchange.com/questions/217297/interpret-interval-notation/217302?noredirect=1#comment506870_217302) [ovs](https://codegolf.stackexchange.com/users/64121/ovs)
## How it works
```
ṣ”Uµṙ1“(Ḋ)Ṗ,r”yḟØ[V)FQ - Main link. Takes a string S on the left
ṣ”U                    - Split S on "U"
   µ               )   - Over each section R in the split S:
    ṙ1                 -   Rotate by once, shifting the first character to the end
      “(Ḋ)Ṗ,r”         -   Yield "(Ḋ)Ṗ,r"
              y        -   Transliterate; Replace "(" by "Ḋ", ")" by "Ṗ" and "," by "r"
                Ø[     -   Yield "[]"
               ḟ       -   Remove "[]"
                  V    -   Eval as Jelly code
                    F  - Flatten
                     Q - Deduplicate
```
### Why `r`, `Ḋ` and `Ṗ`?
As we only consider each individual range in the transliterate-then-eval stage, we'll just take a look at the four possible examples:
```
[0,5] -> 0r5
[0,5) -> 0r5Ṗ
(0,5] -> 0r5Ḋ
(0,5) -> 0r5ṖḊ
```
In Jelly, `r` in the infix inclusive range command, so `0r5 ⁼ [0,1,2,3,4,5]`. `Ḋ` is dequeue (i.e. remove first element) and `Ṗ` is pop (remove last element). So `r` generates the range, then we remove the first and/or last elements if necessary, creating exclusive ranges.
[Answer]
# [Perl 5](https://www.perl.org/) `-MList::Util=uniq -FU`, 53 bytes
```
say for uniq map{($a,$b)=/-?\d+/g;$a+/\(/..$b-/\)/}@F
```
[Try it online!](https://tio.run/##jZI9b4MwEIb3/AorYrAbH8Z8RGoQbSemdmQCBqJ@CCkNNNChqtqfXnoGFxzI0MU@3/u85nxH/XQ6BF1TfKwBYB1acQoyj74bQewrIUKlkOfqRN6P5Rt5LepPahXc2rNIwG32uBEvoVVsREaFbVt7EBkTX3dx16UOD3ICNwQDyV3ucR8TKzqmjaRi2Tk7kMwkkbvm0hvcGCEruXRVapVCwLHsXlKhz8Hj4Kqc1thcwy@YJtNBTceIp7i7mtYo7@vVEltI6qbJYxqoYZhofL6je9a/Xx8GgemYGrFqje4RCuNhKMhhCbLerOK@mSOQLgHnDMn/hbh/QzWQaboSV8X4y8EPE0hS2KoWXxgfh61@prrBwxWtuPrzn@OnqtuyOjYdPAS2Ix3c78um3e2StjxE6uftIE5@AQ "Perl 5 – Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 66 bytes
```
ToExpression[(#/.{"["->"Range[","("->"Range[1+",")"->"-1]"})<>""]&
```
[Try it online!](https://tio.run/##bZDBSsQwEIbvfYwpLClONGlaUdCyIN5FvQ05hNJ1e9iutD0Iy@7Fo2/pi9SmcVoXPM0/X35m/snO9dtq5/q6dMPmfnjdP368t1XX1fuGRHx1eQACWcCza94qAgSxdPpi7BPfS23hmNwVAHY1PLV101Msi836YetaV/ZV261juzq9lK45HSIghbkFjECw8CRhMgm6RW3Cm8zRL5hlMC5ULJSkwdTO6tfJTMxs3Kc4geIEihMEQZoHsPAzVfL99Tl6jD0jdEbs/yTla/UoAsj@nuiRvEaZ2nl/cJmpGsymmvEXpRiu9oly1BzboL7xRoiOww8 "Wolfram Language (Mathematica) – Try It Online")
Input a list of characters.
[Answer]
# [Ruby](https://www.ruby-lang.org/) `-nl`, 69 bytes
```
p eval"[*#{gsub /[(),U-\]]/,?(=>'1+',?)=>'-1',?,=>'..',?U=>',*'}]|[]"
```
[Try it online!](https://tio.run/##XY/NCsIwEITvPkXRQxPd2KRpBQ/ap@hp3YOCiCBa/ANRX9242VoFL7PfZNhhc7ysbiE0yfq63PVxOLhvTpdVkqHSUJsFUQaVms1TN0qh0gzGMQDDeMxQM8AwfdIDqR8CWiipp0Qja2Hdwyk4z0@mBOO6yeHHq49H4yGndsRUnGod11mptlJtpZoVc4ibTjZE47rVNceeOoM/Q38ml2Mda@Tie2WNZgImp7Y7Zp7VQ8Fa8Kdeh@a8PexPwex3bw "Ruby – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 22 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
ṣ”UµØ(fOị⁾ṖḊvṖḊVr/Ʋ)ẎQ
```
A monadic Link accepting a list of characters which yields a list of integers.
**[Try it online!](https://tio.run/##y0rNyan8///hzsWPGuaGHtp6eIZGmv/D3d2PGvc93Dnt4Y6uMggVVqR/bJPmw119gf8Ptx@d9HDnjP//laINdYw0Q6ONdIyBpLGOCZA00THVVAIA "Jelly – Try It Online")** (Footer formats the resulting Jelly list as a Python list.)  
Or see the [test-suite](https://tio.run/##y0rNyan8///hzsWPGuaGHtp6eIZGmv/D3d2PGvc93Dnt4Y6uMggVVqR/bJPmw119gf8f7tgEVNd@dNLDnTMe7lwbrun@/3@0gY5prIIGmASxNcFsTYVoSx1DY6CQrqmOriGMBkpC@RpQfrSusY5RLIQCyYJ5GhAe0DgDsNEGYKMNwEYDyWhDsFowCdJooBkKlDCOhXGiEZxYNI4R2JmGQBLENoG7LzRa10xH1ygWYjZIzhhIGuuYAEkToHcA "Jelly – Try It Online").
### How?
```
ṣ”UµØ(fOị⁾ṖḊvṖḊVr/Ʋ)ẎQ - Link: list of characters, S
 ”U                    - literal character = 'U'
ṣ                      - split (S) at ('U's)
   µ               )   - for each part, P:
    Ø(                 -   literal list of characters = "()"
      f                -   filter keep (characters of P which are one of "()")
       O               -   to ordinals - i.e. '(' -> 40  and  ')' -> 41
         ⁾ṖḊ           -   literal list of characters "ṖḊ"
        ị              -   index into    ...      -> 'Ḋ'          -> 'Ṗ'
                  Ʋ    -   last four links as a monad, f(P):
             Ṗ         -     pop - i.e. remove ']' or ')' from the right of P)
              Ḋ        -     dequeue - i.e. remove '[' or '(' from the left of P)
               V       -     evaluate as Jelly code - e.g. "-4,2" becomes the list [-4,2]
                 /     -     reduce with:
                r      -       inclusive range            ...and then [-4,-3,-2,-1,0,1,2]
            v          -   evaluate (the string of "ṖḊ" characters)
                           as Jelly code with input (the inclusive range)
                    Ẏ  - tighten (to a single list)
                     Q - de-duplicate
```
[Answer]
# JavaScript (ES6), 104 bytes
Returns a set.
```
s=>s.replace(/(\[?)(-?\d+),(-?\d+)(]?)/g,(_,a,b,c,d)=>(g=_=>b>c-!d||g(S.add(b++)))(b-=-!a),S=new Set)&&S
```
[Try it online!](https://tio.run/##pZTLjoIwFED38xXowtwbb3lrMovCRxBXSAwvyUyMGDEzG/@daR0ncWwpGllA0t7DKdzHZ/6Vd@Xx43Bi@7aq@y3vOx519rE@7PKyBgfWaYzA4nU1R7o@IYvRaQg2lFNBJVXII2j4hkdFVLJJdT43kNh5VUExnyMiFIyzSY6U8H39bSX1CWezpC/bfdfuanvXNrCFaerSIpsiWurlOJbY9cingEIR9XaHghkdBqUTH3BqjThqVH3v5AX6k0pM7AqlR54vwxSYLYh5WlrCcjckFhDzZZiexgdo9WNHxAYrjFiHlKlY9od/1J@PLhnS0/gQrTmx2WzQwoh20CkKzTWVvq78TIBWgE/Ew5PxsuBN7aAKzIA2oy6uxLmU9vmX0UvjDdHpGO2a@Ox13lfH1B0/OKg8sShfECppH5lwv727StlS9tktrA4NYkt9aqU5EHfhEPfwOvtuJ13/Aw "JavaScript (Node.js) – Try It Online")
### Commented
```
s =>                           // s = input sequence
s.replace(                     // match in s all occurrences of:
  /(\[?)(-?\d+),(-?\d+)(]?)/g, //   (\[?)   an optional opening bracket (a)
                               //   (-?\d+) a number preceded by an optional '-' (b)
                               //   ,       a comma
                               //   (-?\d+) another number in the same format (c)
                               //   (]?)    an optional closing bracket (d)
  (_, a, b, c, d) => (         //
    g = _ =>                   //   g is a recursive function ignoring its input
      b > c - !d ||            //     abort if b is greater than c, or greater than
                               //     c - 1 if d is not defined
        g(S.add(b++))          //     otherwise: add b to S, increment b and do a
                               //     recursive call
  )(b -= -!a),                 //   initial call to g; increment b if a is not defined
  S = new Set                  //   initialize S to a set
) && S                         // end of replace(); return S
```
[Answer]
# [J](http://jsoftware.com/), 60 bytes
```
[:~.@;'U'<@([:({:+[:i.0>.-/)(']('={:,{.)+3 1".@;@{;:);._1@,]
```
[Try it online!](https://tio.run/##lZPLSsQwFIb3PsXPbNIwacylHZjUkYLgypUwqxKyEAd14wMUfPWatqTXVGqgWX185@Sc/l/NgZMbLgYEDALGfynH0@vLc1OZH14W5EoeyqQySW2Olfnk4pGn9zQhNiGX2rCa06OGPHiyrAtDC@5kyWxD797fPr69TUJBI0OO8aQGN5BKsNySnotRgUsm3OhD1EcXPmz4AneG9EoJqSD10ndmUofCLofL4DScgpML0OXMyRi5arEjQ/GIcGxy7lwLF@TgDMJ@UovqmikbAxEBB@NaN6k9Na51czAYE2YEBaLL8UsUQUgIImdY4i6u9dGdvkl/crM/Ob7jT9@EG0bd/5WrUQt69eW1ja9QR/DqP7jdwieRm@NqXzD9LPKOzjZS4k7rlFwrd2JO2R1B7Wbd@rW/Ncv8nbXRbX4B "J – Try It Online")
* `'U' ...;._1@, ]` - Prepend `'U',` to the input `]` and cut it using the first character `;._1`, ie `U`, as a delimiter, applying the verb defined by `...` to each piece. Now we'll breakdown what's in `...`:
* First we turn it into boxed words `;:`, so for example `'(_5,2]'` becomes:
```
┌─┬──┬─┬─┬─┐
│(│_5│,│2│]│
└─┴──┴─┴─┴─┘
```
and we take elements from indexes 3 and 1 `3 1 ... {` (the numbers) and unbox and convert then to ints `".@;@`. We take them in reverse order, right endpoint first, because it ends up saving bytes in a later step.
* `('](' = {: , {.) +` This adds an adjustment to each of the numbers, based on endpoint type. `{:,{.` returns the last and first character, and `](=` does an element-wise comparison, which will return 1 when equal, 0 otherwise. Thus the original input's right endpoint is incremented when it is `]`, and its left endpoint is incremented when it's `)`.
* `({: + [: i. 0 >. -/)` The adjusted, reversed endpoints are now passed to this phrase, which sticks a minus sign between them `-/`, and takes the maximum of that result and 0 `0 >.` (this is to account for the `(0,0)` case, which would otherwise return `_1`). We then generate the integers up to, but not including, that result `i.` and add the original input's adjusted left endpoint `{:` to all of them. We now have the correct range of numbers for a single range.
* `<@` And we box that up, to avoid fill when pieces of unioned input of different lengths are combined.
* `[: ~.@;` Finally we unbox the combined result to get a single list `;` and dedup it `~.@`.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 46 bytes
```
ＦＥ⪪ＳU⪪ι,Ｆ…⁺ＩΦ§ι⁰λ№§ι⁰(⁺Ｉ⮌Φ⮌§ι¹λ№§ι¹]Ｆ¬№υκ⊞υκＩυ
```
[Try it online!](https://tio.run/##bY8xC4MwEIX3/grJdIEUtKWTUxEKDi2iOIlDsKlKQ5R4kf77NDaIpXQ5ePfufXfXdFw3A5fWPgYdwJWPUIyyR0jVaLBA3asWKAtISVz1Vu8kI5TS4JPJuWoFZNJMkPAJ4dJLFBrOmKq7eC3ToYtK6koyGIW/DgGyeBsgF7PQk1hBq/yKRdQT/yGjBVlv590GBD9kWPBc2pmZOi/iXeYeRL/WUBpbW5Fqf2RhXVYHdqpJbfezfAM "Charcoal – Try It Online") Link is to verbose version of code. Uses `U` as the union operator. Explanation:
```
ＦＥ⪪ＳU⪪ι,
```
Split the input on `U` and then split each part on `,` and loop over each pair of parts.
```
Ｆ…⁺ＩΦ§ι⁰λ№§ι⁰(⁺Ｉ⮌Φ⮌§ι¹λ№§ι¹]
```
Form a range from the integer in the first part (excluding the first character) and the integer in the second part (excluding the last character), except increment the first integer if the first part contains a `(` and increment the second integer if the second part contains a `]`, and loop over the range.
```
Ｆ¬№υκ⊞υκ
```
Push any new integers to the predefined empty list.
```
Ｉυ
```
Print all of the collected integers.
[Answer]
# [R](https://www.r-project.org/), 148 bytes
```
function(s)unique(unlist(lapply(parse(t=chartr("[],","():",gsub(",(-?\\d))",",(\\1-1))",gsub("\\((-?\\d)","((1+\\1)",el(strsplit(s,"U")))))),eval)))
```
[Try it online!](https://tio.run/##RY3LDoIwEEX3foXpaiZOE8rDhdH4FawoC0RQkgaxDxO/HgeE0MX05Nw7rR3b/VmObehr3716cBj67h0aCL3pnAdTDYP5wlBZ14C/1M/KeguiKEmQADwJerhwA0Egr1rfEVkTaK2kmvgfag1LPC2BOnDO2Bhw3rrBdB4ciVzgfKj5VIbvseV/IspKgTtG2HCyuNkFC5lQhDmbZO0pXsmLmNJVyIykYiWPJOOtFePUSngmlPJM50fHHw "R – Try It Online")
If there's a shorter way, I can't seem to think of it.
[Answer]
# [Zsh](https://www.zsh.org/), ~~89~~ 84 bytes
```
for i (${(s"U")1}){seq $[${${i%,*}#?}+1-#i&1] $[${${i#*,}%?}-!(##$i[-1]&4)]}|sort -u
```
[Try it online!](https://tio.run/##NcixDkAwEADQXyl3pKWXaGr3FaamI9FJKIu6bz@TN74nbyLrfqqkNBad67k2jk3Jy6EwYMGSGtsxTNw7gtS6@Dd0lpuJqdIAmAK52I4m8pv381J0i0ggbwcz68H6@AE "Zsh – Try It Online")
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell) for Windows, ~~133~~ 114 bytes
```
$(switch -r($args){'\('{$l++}','{$l+=+$n}'\)'{$n-=1}'\)|]'{$l..$n*($l-le$n)
$l=0}\D{$n=''}'\d|-'{$n+=$_}})|sort -u
```
[Try it online!](https://tio.run/##jZRtb9owEMff51N4rbfY41zFhIdWVaROmybtVachXgVUUTAtVZqwPKjTIJ@dnZMAxhnT8iI53/1/9vl88Tp5U2n2rKJoR5ckIJsdZdnbKp8/E5EyOkufMr5xJ8zd0KjTKV2ojKBD49KdcBzEIpDa3E515OqKxh8ZjUSkaMwdGgVeOfmCqsB1UbXYCo10AvpQlnybJWlORLErHeeOOQ4wN/SgP3WBaENCF3zoaQfXMXaI2RFN8VPKYLjJ7IkbkH49GVpISZDdylWHRR@ErOPa7IHwQXQrnyHgtmC/qom3WGayp2CIg27DNRBUWzLjvBU/THykWygzUIvDqnlN0Y9lazyGhJsOZjt0gZtK7yUHj5G9x8eI@tYeq8M5VYVtldfWTf9f1913j6Gz2kiiqYW9M21WH@s4FIPqyKrJ0LQbhFyS@3Sh0nc25J1hwPv7CvgdHqAh/IPTpdaZ@/jGlPHdO9P42OWHQyHWc0nG8UItV7FaaO2Y9fHfqNUDGMI13BwhSxtKH@Q1H9dLot0DifQA5LBmTL3DyZa8JxtHT0SzPF3FT0Co@rVW81wt8BqiD3UsVVkR5ej4gLfTXa00I1@T9HWW18xFSFnjFi/JKsa7ik8vKnX4ffS5yPLk9f7xBZeY3m3IqJjPVZbpteyphPp5TOaWfIvXhU6hSfSW/Ngn1SJLp8SdLauxyGePkSLiU5Eno9VvtfsD "PowerShell – Try It Online")
Less golfed:
```
$numbers = switch -Regex ($args){
    '\('    {$left++}
    ','     {$left+=+$num}
    '\)'    {$num-=1}
    '\)|]'  {$left..$num*($left -le $num);$left=0}
    '\D'    {$num=''}
    '\d|-'  {$num+=$_}
}
$numbers|sort -u
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 137 133 bytes
-4 bytes thanks to Mazzy, who has an even cooler PS solution to this challenge!
```
$r="'|% rep* '"
"'('+('$args$r(','[1+$r)','-1]$r]','))$r[','(($r,' '),($r`U' ',')+',0)'"|iex|iex|%{$l,$n=$_;$l..$n*($n-ge$l)}|sort -u
```
[Try it online!](https://tio.run/##jVJRb5swEH7nVyDrOuNyRBCSthKyFKnapL2s1VqeUNQmmddmIpDZoFVK@O3pGULWF9paMj58n7/vu7O35T@lzbPK8wP8rotVtS4LuTuAlozvz1yttucuZw7jHvc9Dgv9ZEB7HHkW@aAFBUE0Bz2nQAjQGa2eBxq5ywVS8JhSRDmfYyg426/VSzvPdpAjFBIeEshHIyjOPSiCJwW5aPam1JUb1IfGgUqZ6nphlHGlO/Mcl8Zs1y52rIttXdnAJlkWTJHcpFlwgcHYrpcYzpk4wdXLVq0q9auFU9Li6MgEg5gO0Fny2IIbHBaJYoyuRDpEa9MTjKYYXWB0@SGdF5LmENfHZsJ3CvxELVR3KFLyEA@3qW9NhGOMP9EeHIs0s9A0i3FC3wlOBytsSQnV0TrCgXu6cCNt7f/v3r4W@/Oj3iyVllHTqUMrjdAz0mMaHbceRv1mh9TK1Hklv5zeuDtrkV3W1KuVMkayI44F6i870bIO1BrzZXZ7d12bqtzcLP9Qej7bcZvh8o1D30/ujpQ9d/LdypFCK8uSn52hk2LytS/ijXDjNMeG7L@VerOogvvFMleHVw "PowerShell – Try It Online")
[Answer]
# [QuadR](https://github.com/abrudz/QuadRS), 40 bytes
Uses `∪` and `¯` instead of `U` and `-`
```
⍎⍵
\[
\(
,
\)
]
(
(1↓
{⍺+0,⍳0⌈⍵-⍺}
-1)
)
```
[Try it online](https://tio.run/##KyxNTCn6//9Rb9@j3q1cMdFcMRpcOlwxmlyxXBpcGoaP2iZzVT/q3aVtoPOod7PBo54OoDJdoEAtl66hJpfm///Rh9ab6hxabxj7qGMVkG0GZBtB2eY6BrEA "QuadR – Try It Online") or [try them all](https://tio.run/##dVA7DsIwDN19kkS4UtK0fHZukWZAYkYCiQmxIVQJwsItWDogFsYeJRcJjluVDrDY7z2/@JPtfrXexRj8LfgXVBYqAQiVBAfVBgQIHc53OAT/nigM/qnCtSZnRsIRMi1BQricYrQKSweCY8KSsQS7QG1IapsS20Z/ERkGTQwaVQ3mrs/sYS56Tq0Vj1E8RvEYilazmyO/VTLUD6oZN@J2xN0vnvP6mmLHitHmSWmbKeH8h6r@ODs843rarutrOBssOBf8UTnS/WnpEjVfZFDPUz0uPw "QuadR – Try It Online")!
Execute (`⍎`) it (`⍵`) after simple transliteration to APL:
| In | Out | Explanation |
| --- | --- | --- |
| `[` | `(` | Open group |
| `(` | `(1↓` | Open group but with first element (the start) removed |
| `,` | `{⍺+0,⍳0⌈⍵-⍺}` | Anonymous infix lambda to compute range (see below) |
| `)` | `-1)` | Close group but subtract one from the end |
| `]` | `)` | Close group |
The "try them all" link also replaces `\n` with APL's statement separator `⋄`, and runs in **D**ocument mode.
### The infix range lambda `{⍺+0,⍳0⌈⍵-⍺}`
`{`…`}` "[dfn](https://apl.wiki/dfn)"; left and right arguments are `⍺` and `⍵`:
 `⍵-⍺` difference
 `0⌈` maximum of zero and that; nulls negative differences like `[3,3)` → `(3`…`3-1)`
 `⍳` **ɩ**ndices one through that
 `0,` prepend zero
 `⍺+` add start point to all of those
[Answer]
# [Haskell](https://www.haskell.org/), 194 180 bytes
```
import Data.List
a=init
l=drop 1
t""=[]
t c=nub$i v++t(l n)where(v,n)=span(/='U')c
i('(':c)=l$i('[':c)
i c|last c==')'=a$i$a c++"]"|1<2=f$span(/=',')c
f(_:o,_:w)=[read$o..read$a w]
```
[Try it online!](https://tio.run/##lVNRa9swEH7XrziMIRKRu9hJCwvTHsZgDPo2@uSaojpuI@bawVabPfS/ZyfJSSQ7he3Flu77vpN0d99W9r@ruj4c1Muu7TR8l1pe3apeEylUozSpxaZrd5ASHUUiL4iGUjSvj7GCt/lc0xoatt9WXUXfeMNEv5MN/SRmdzNWEkVndLYumahjXOZmSRSU77XsTRYxYzMhYxVLKOfzqIje0y@ZeIqPObjJ8UQf1i1/WO@ZyLtKbuL26sr@JeyLQyn7qof1GnL6S3eqeeaQ/2x0wQriIAE5AaBRvuDXRYTogqc840u@wj1DiCNIj@AUMjoW6AIV81RnzWeeLm0@XKAu5WlmIic8ueZJaglmteLJkieZCYUMNmKcT/YSXFBTTz2W5rjNnHKQcfuykMDGBC/3SX9BTM/iiRIruHAd8CvoQgGJBRE6iZh6u7qfScdQ8IwFu0P1MnytbdaYlk9oi0vE4j@I2TBSHnEyWyluDHP10fC5Pt/lyY3p4XRgeHITlsVkW@IX8@B3NR7QgpAXqRp0xaZFWV1pUI2uujdZG6voIUaf23bD4VFuGEZ3stNKq7YBek9Vs3vVHKo/u6rUFeLJVy@FRUEID4/BGhEzI4QevW0wFP3AA9YQwXwO/bbdgzlwRPkmAwZexhK6CigjB@tnc3hgaEJPYS9oPRxyHZP5TORZ39pYaFwyNMJCI8sOGBtjeIIv8hXUV5zozpkuGFrTQWwCmUxnjS@gnuDMtg50dbDvHzYOYMOaems7Uq5GCJw27kJHd4XXcmYgvq8uPOlEKf6Jkh2besFMxHPRpPGhfy60zxiIfOCcYDj@Ag "Haskell – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 28 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
'U¡ε¦¨',¡ŸÙy„()©Ã®"¦¨"‡.V}˜ê
```
[Try it online](https://tio.run/##yy9OTMpM/f9fPfTQwnNbDy07tEJd59DCozsOz6x81DBPQ/PQysPNh9YpgSSUHjUs1AurPT3n8Kr//5WUlKJ1TXV0DWNDo3XNdHSNQLS5jkEsUAIA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeV/9dBDC89tPbTs0Ap1nUMLj@44PLPyUcM8Dc1DKw83H1qnBJJQetSwUC@s9vScw6v@6/yPVoo20DGNVdJR0oDSIL4mlA@ioy11DI3BErqmOrqGCBZYEVxMAy4WrWusYxQLY0BUQUU0YCJASwyglhpALTWAWgqmow2hOqE0yCgDzVCgtHEsghuNzI3F4BpBPWQIpEE8EyRfhEbrmunoGqGLGGBRAqTNoRIg14BMMgaSxjomQNIEFEixAA).
**Explanation:**
```
'U¡              '# Split the (implicit) input-string on "U"
   ε              # Map over each interval:
    ¦¨            #  Remove the first and last characters (the "[]()")
      ',¡        '#  Split on ","
         Ÿ        #  Transform that pair of integers into a ranged list
          Ù       #  And uniquify it
                  #  (if a==b in [a,b], it will result in pair [a,a] instead of [a])
    y             #  Push the interval-string we're mapping over again
     „()          #  Push string "()"
        ©         #  Store it in variable `®` (without popping)
         Ã        #  Keep only the "()" in the interval-string (if any)
     ®            #  Push "()" from variable `®` again
      "¦¨"        #  Push "¦¨"
          ‡       #  Transliterate "(" to "¦" and ")" to "¨"
           .V     #  Evaluate and execute it as 05AB1E code:
                  #   `¦`: Remove the first value from the list
                  #   `¨`: Remove the last value from the list
   }˜             # After the map: flatten the list of lists
     ê            # And sort and uniquify the values
                  # (after which the result is output implicitly)
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~107~~ 62 bytes
```
⍎'\]' '\[' ',' '\(' '\)'⎕R')' '(' '{⍺+⍳0⌈1+⍵-⍺}' '(1↓' '-1)'⊢⎕
```
[Try it online!](https://tio.run/##dZA9asNAEIV7nSLdSmQEO1rJJEdwZUi72kJgnMZgt8akdYSxTCDkAinTqAhpUuoocxF5VhJjS@Bm55s3P7ydYruOl7tivXlt6fw1X9DhQwdUvq9aqs4qd@pB5ZYf8BD6J1Lc@KIiZp/vqfp/pOpX06lEhr@YhTdfRDp8coyRJ47fPNTy3nYVKKshcypgCoW8FonWk30GNEO5qTNoahxnw8CoFo5q3GkgcTcsM6KHNzrb0GJNizUt1gayKJuEuv06ovKH@4ybaHaiuXtaIidBpl5JJ1fwalPPmBN39dP3mi4aSLuYyjETGG7iDWaA8hMD@OR71QU "APL (Dyalog Unicode) – Try It Online")
Does a huge regex replacement and then executes the string.
uses `∪` and `¯` for input.
Uses `⎕IO←0` (0-indexing)
-45 bytes by stealing a ton from [Adám's QuadR answer](https://codegolf.stackexchange.com/a/217443/80214)(It has a well-written explanation, go upvote it!).
]