def slice(arg, length = (missing_length = true))
      raise Erlang::ImproperListError if improper?
      if missing_length
        if arg.is_a?(Range)
          from, to = arg.begin, arg.end
          from += size if from < 0
          return nil if from < 0
          to   += size if to < 0
          to   += 1    if !arg.exclude_end?
          length = to - from
          length = 0 if length < 0
          list = self
          while from > 0
            return nil if list.empty?
            list = list.tail
            from -= 1
          end
          return list.take(length)
        else
          return at(arg)
        end
      else
        return nil if length < 0
        arg += size if arg < 0
        return nil if arg < 0
        list = self
        while arg > 0
          return nil if list.empty?
          list = list.tail
          arg -= 1
        end
        return list.take(length)
      end
    end
def slice(arg, length = (missing_length = true))
      raise Erlang::ImproperListError if improper?
      if missing_length
        if arg.is_a?(Range)
          from, to = arg.begin, arg.end
          from += size if from < 0
          return nil if from < 0
          to   += size if to < 0
          to   += 1    if !arg.exclude_end?
          length = to - from
          length = 0 if length < 0
          list = self
          while from > 0
            return nil if list.empty?
            list = list.tail
            from -= 1
          end
          return list.take(length)
        else
          return at(arg)
        end
      else
        return nil if length < 0
        arg += size if arg < 0
        return nil if arg < 0
        list = self
        while arg > 0
          return nil if list.empty?
          list = list.tail
          arg -= 1
        end
        return list.take(length)
      end
    end
Return specific objects from the `List`. All overloads return `nil` if
 the starting index is out of range.

 @overload list.slice(index)
   Returns a single object at the given `index`. If `index` is negative,
   count backwards from the end.

   @param index [Integer] The index to retrieve. May be negative.
   @return [Object]
   @example
     l = Erlang::List["A", "B", "C", "D", "E", "F"]
     l[2]  # => "C"
     l[-1] # => "F"
     l[6]  # => nil

 @overload list.slice(index, length)
   Return a sublist starting at `index` and continuing for `length`
   elements or until the end of the `List`, whichever occurs first.

   @param start [Integer] The index to start retrieving items from. May be
                          negative.
   @param length [Integer] The number of items to retrieve.
   @return [List]
   @example
     l = Erlang::List["A", "B", "C", "D", "E", "F"]
     l[2, 3]  # => Erlang::List["C", "D", "E"]
     l[-2, 3] # => Erlang::List["E", "F"]
     l[20, 1] # => nil

 @overload list.slice(index..end)
   Return a sublist starting at `index` and continuing to index
   `end` or the end of the `List`, whichever occurs first.

   @param range [Range] The range of indices to retrieve.
   @return [Vector]
   @example
     l = Erlang::List["A", "B", "C", "D", "E", "F"]
     l[2..3]    # => Erlang::List["C", "D"]
     l[-2..100] # => Erlang::List["E", "F"]
     l[20..21]  # => nil