Top "Slice" questions

A slice is a representation of a part of a sequence, usually defined by a reference to the underlying sequence, an index giving the starting position, a length or end position, and optionally a "stride" or "step" value.

How to iterate over the first n elements of a list?

Say I've got a list and I want to iterate over the first n of them. What's the best way …

python list slice
Subsetting data.table set by date range in R

I have a large dataset in data.table that I'd like to subset by a date range. My data set …

r data.table subset date-range slice
Declare slice or make slice?

In Go, what is the difference between var s []int and s := make([]int, 0)? I find that both works, but …

go allocation slice
Pairs from single list

Often enough, I've found the need to process a list by pairs. I was wondering which would be the pythonic …

python list zip slice idioms
How should I handle inclusive ranges in Python?

I am working in a domain in which ranges are conventionally described inclusively. I have human-readable descriptions such as from …

python range slice
Any way to hide Slicer Values in Excel 2010

I know that Excel 2010 Slicers will visually indicate when there is no data associated with a particular slicer selection. For …

excel slice excel-2010 powerpivot
Parse JSON array in Golang

Simple question: how to parse a string (which is an array) in Go using json package? type JsonType struct{ Array []…

arrays json go slice
Cutting a string at nth occurrence of a character

What I want to do is take a string such as this.those.that and get a substring to or …

javascript string substring slice
Most idiomatic way to select elements from an array in Golang?

I have an array of strings, and I'd like to exclude values that start in foo_ OR are longer than 7 …

arrays go slice
How do you use the ellipsis slicing syntax in Python?

This came up in Hidden features of Python, but I can't see good documentation or examples that explain how the …

python numpy subclass slice ellipsis