Limit the returned results via slicing embedded arrays.

 @example Slice the returned results.
   optional.slice(aliases: [ 0, 5 ])

 @param [ Hash ] criterion The slice options.

 @return [ Optional ] The cloned optional.

 @since 1.0.0
506268
def slice(criterion = nil)
      option(criterion) do |options|
        options.__union__(
          fields: criterion.inject({}) do |option, (field, val)|
            option.tap { |opt| opt.store(field, { "$slice" => val }) }
          end
        )
      end
    end
417838
def slice( start, length )
      unless start.matched? or length.matched?
        if start < 0 or start + length > shape.last
          raise "Range must be in 0 ... #{shape.last} " +
                "(was #{start} ... #{start + length})"
        end
      end
      start = INT.new start unless start.matched?
      length = INT.new length unless length.matched?
      index = Variable.new Hornetseye::INDEX( length )
      Lambda.new( index, @term.subst( @index => index ).
                         skip( index, start ) ).unroll
    end
916735
def _slice_bounded(self, tuple_key, data_slice):
        
        slices = [el for el in tuple_key if isinstance(el, slice)]
        if any(el.step for el in slices):
            raise Exception("DynamicMap slices cannot have a step argument")
        elif len(slices) not in [0, len(tuple_key)]:
            raise Exception("Slices must be used exclusively or not at all")
        elif not slices:
            return None

        sliced = self.clone(self)
        for i, slc in enumerate(tuple_key):
            (start, stop) = slc.start, slc.stop
            if start is not None and start < sliced.kdims[i].range[0]:
                raise Exception("Requested slice below defined dimension range.")
            if stop is not None and stop > sliced.kdims[i].range[1]:
                raise Exception("Requested slice above defined dimension range.")
            sliced.kdims[i].soft_range = (start, stop)
        if data_slice:
            if not isinstance(sliced, DynamicMap):
                return self._dataslice(sliced, data_slice)
            else:
                from ..util import Dynamic
                if len(self):
                    slices = [slice(None) for _ in range(self.ndims)] + list(data_slice)
                    sliced = super(DynamicMap, sliced).__getitem__(tuple(slices))
                dmap = Dynamic(self, operation=lambda obj, **dynkwargs: obj[data_slice],
                               streams=self.streams)
                dmap.data = sliced.data
                return dmap
        return sliced
290388
private ICriteria addExpressionCriterion(Restrictor criterion) {
		ExpressionRestrictor e = (ExpressionRestrictor) criterion;
		if (this.hasAlias()) {
			queryString.append(this.alias).append(".");
		}
		queryString.append(e.getProperty());
		queryString.append(e.getRestriction());
		queryString.append(e.getExpression());
		return this;
	}
871034
function slice(args, begin, end) {
  return Array.prototype.slice.call(args, begin, end);
}
893305
protected List splitInCriteria(Object attribute, Collection values, boolean negative, int inLimit)
    {
        List result = new ArrayList();
        Collection inCollection = new ArrayList();

        if (values == null || values.isEmpty())
        {
            // OQL creates empty Criteria for late binding
            result.add(buildInCriteria(attribute, negative, values));
        }
        else
        {
            Iterator iter = values.iterator();

            while (iter.hasNext())
            {
                inCollection.add(iter.next());
                if (inCollection.size() == inLimit || !iter.hasNext())
                {
                    result.add(buildInCriteria(attribute, negative, inCollection));
                    inCollection = new ArrayList();
                }
            }
        }
        return result;
    }
95024
def _linear_selection(self, non_empty_slices, num_slices):
        """"""

        num_non_empty = len(non_empty_slices)

        # # trying to skip 5% slices at the tails (bottom clipping at 0)
        # skip_count = max(0, np.around(num_non_empty * 0.05).astype('int16'))
        # # only when possible
        # if skip_count > 0 and (num_non_empty - 2 * skip_count > num_slices):
        #     non_empty_slices = non_empty_slices[skip_count: -skip_count]
        #     num_non_empty = len(non_empty_slices)

        sampled_indices = np.linspace(0, num_non_empty, num=min(num_non_empty, num_slices),
                                      endpoint=False)
        slices_in_dim = non_empty_slices[np.around(sampled_indices).astype('int64')]

        return slices_in_dim
100677
def expr_query(criterion)
      selection(criterion) do |selector, field, value|
        if (field.is_a? Key) && custom_serialization?(field.name, field.operator)
          specified = custom_specify(field.name, field.operator, value)
        else
          specified = field.specify(value.__expand_complex__, negating?)
        end
        selector.merge!(specified)
      end
    end
1271417
def subset( *keys, &select_block )
      subset_params =
      if block_given?
        filter_parameters.select &select_block
      else
        filter_parameters.slice( *keys )
      end
      subset = self.class.new( subset_params )
      subset.predicates = predicates.clone
      subset
    end
1354762
def slice(*keys, **options)
      return super if options.include?(:raw)
      new_expires = expires_at(options, nil)
      options = Utils.without(options, :expires)

      with_updates(options) do |updates|
        @adapter.slice(*keys, **options).map do |key, entry|
          entry = invalidate_entry(key, entry, new_expires) do |new_entry|
            updates[key] = new_entry
          end
          next if entry.nil?
          value, _ = entry
          [key, value]
        end.reject(&:nil?)
      end
    end
6120
def multiget_slice(self, keys, column_parent, predicate, consistency_level):
    
    self._seqid += 1
    d = self._reqs[self._seqid] = defer.Deferred()
    self.send_multiget_slice(keys, column_parent, predicate, consistency_level)
    return d
462006
function filterResults(results, maximum) {
  var filteredResults = []
  var indices = []
  var matrix = {}
  var column
  var key
  var score
  var interpolated
  var index
  var otherIndex
  var maxScore

  for (key in results) {
    score = results[key].score

    if (!matrix[score]) {
      matrix[score] = []
      indices.push(score)
    }

    matrix[score].push(results[key])
  }

  indices.sort(reverse)

  maxScore = indices[0]

  index = -1

  while (indices[++index]) {
    score = indices[index]
    column = matrix[score]

    interpolated = score / maxScore
    otherIndex = -1

    while (column[++otherIndex]) {
      column[otherIndex].score = interpolated
    }

    filteredResults = filteredResults.concat(column)

    if (filteredResults.length >= maximum) {
      break
    }
  }

  return filteredResults
}
170826
def visit_Slice(self, node):
        
        self.generic_visit(node)
        if node.step is None or (isinstance(node.step, ast.Num) and
                                 node.step.n == 1):
            self.result[node] = self.builder.NamedType(
                'pythonic::types::contiguous_slice')
        else:
            self.result[node] = self.builder.NamedType(
                'pythonic::types::slice')
41851
def last(cls, *criterion, **kwargs):
        
        kwargs['reverse'] = True
        return cls.first(*criterion, **kwargs)
1110331
function slice (ar, start, end) {
    return Array.prototype.slice.call(ar, start, end)
  }
358841
def all(options={})
      offset = nil
      results = []
      begin
        options.merge!(:limit => LIMIT_MAX, :offset => offset)
        response = records(options)
        results += response.records
        offset = response.offset
      end until offset.nil? || offset.empty? || results.empty?
      results
    end
1152662
def sort_criteria
      @sort_criteria ||=
        sort_params.reduce('') do |sum, (key, value)|
          comparables = ["a[:#{key}]", "b[:#{key}]"]
          comparables.reverse! if value == :desc
          sum + "comp = comp == 0 ? #{comparables.join(' <=> ')} : comp; "
        end
    end