Interpret loose ranges Interpret loose ranges
ListSharp is an interpreted programming language that has many features, one of those features is a 1 index based range creator that works like this:
You define a range as (INT) TO (INT) or just (INT) where both or the single int can go from min to max int32 value
Then you can use those ranges to extract elements of an array without fearing to overstep it's boundaries

therefore:
1 TO 5 generates: {1,2,3,4,5}
3 generates: {3}
Ranges can be added up using the AND operator
1 TO 5 AND 3 TO 6 generates: {1,2,3,4,5,3,4,5,6}
remember this works with negative numbers as well
3 TO -3 generates: {3,2,1,0,-1,-2,-3}

The challenge is the following:
Input
A character array and the previously defined range clause as a string
Output
The elements at the 1 index based locations of the range (non existing/negative indexes translate to an empty character)

How to win
As a code-golf challenge you are supposed to create the program with the shortest byte count to win

It has been pointed out empty characters do not exist, therefore you should be ignoring them (I only showed them here to make it easier to understand yet it confused people)
Test cases:
input array is:
{'H','e','l','l','o',' ','W','o','r','l','d'}

range clause:
&quot;1 TO 3&quot; =&gt; &quot;Hel&quot;
&quot;5&quot; =&gt; &quot;o&quot;
&quot;-10 TO 10&quot; =&gt; &quot;Hello Worl&quot;
&quot;0 AND 2 AND 4&quot; =&gt; &quot;el&quot;
&quot;8 TO 3&quot; =&gt; &quot;oW oll&quot;
&quot;-300 AND 300&quot; =&gt; &quot;&quot;
&quot;1 TO 3 AND 3 TO 1&quot; =&gt; &quot;HelleH&quot;
&quot;-20 TO 0 AND 1 AND 4&quot; =&gt; &quot;Hl&quot;
Python 2 - 239 211 210 bytes

Thanks to @mbomb007 and @Cyoce for further golfing this solution!

def r(s):
 t=[]
 for x in s.split("AND"):
  if"T"in x:a=map(int,x.split("TO"));b=2*(a[0]&lt;a[1])-1;t+=range(a[0],a[1]+b,b)
  else:t+=int(x),
 return t
lambda p,v:[(['']+p+['']*max(map(abs,r(v))))[x]for x in r(v)]


Straight-forward approach. Tried generators and a recursive version, but they couldn't beat the simple for each loop. I'm a golfing noob, so this can most likely be improved quite a bit. Also, the major flaw of this snippet is that the range as a list object is computed again each time an element is retrieved from the character array (see last line, list comprehension). This means r(s) is executed len(r(s)) + 1 times.

Ungolfed code:

def find_range(string):
    result = []

    # Split at each AND and look at each element separately
    for element in string.split("AND"):
        # Element is just a number, so add that number to the result list
        if "TO" not in string:
            result += [int(string)]

        # Generate a list with all the values in between the boundaries 
        # (and the boundaries themselves, of course) and append it to the result list
        else:
            boundaries = map(int, string.split("TO"))
            ascending = boundaries[0] &lt; boundaries[1]

            # range(start, stop, step) returns [start, ..., stop - 1], so extend the stop value accordingly
            # range(8, 3, 1) returns just [], so choose respective step (negative for a descending sequence)
            result += range(boundaries[0], boundaries[1] + (1 if ascending else -1), 1 if ascending else -1)

# Make the char array 1-indexed by appending an empty char in 0th position
# Add enough empty chars at the end so too large and negative values won't wrap around
interpret = lambda chars, range_expr: [(['']+chars+['']*max(map(abs, find_range(range_expr))))[x] for x in find_range(range_expr)]


Test cases:

c = list("Hello World")
print interpret(c, "1 TO 3")
print interpret(c, "5")
print interpret(c, "-10 TO 10")
print interpret(c, "0 AND 2 AND 4")
print interpret(c, "8 TO 3")
print interpret(c, "-300 AND 300")


Output:

['H', 'e', 'l']
['o']
['', '', '', '', '', '', '', '', '', '', '', 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l']
['', 'e', 'l']
['o', 'W', ' ', 'o', 'l', 'l']
['', '']