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.

What is the difference between String.slice and String.substring?

Does anyone know what the difference is between these two methods? String.prototype.slice String.prototype.substring

javascript substring slice substr
Correct way to initialize empty slice

To declare an empty slice, with a non-fixed size, is it better to do: mySlice1 := make([]int, 0) or: mySlice2 := []int{} …

arrays go slice
Grab a segment of an array in Java without creating a new array on heap

I'm looking for a method in Java that will return a segment of an array. An example would be to …

java arrays slice
Slicing of a NumPy 2d array, or how do I extract an mxm submatrix from an nxn array (n>m)?

I want to slice a NumPy nxn array. I want to extract an arbitrary selection of m rows and columns …

python numpy slice
Slice indices must be integers or None or have __index__ method

I'm trying something with Python. I want to slice a list (plateau) in several list (L[i]) but I have …

python slice
What is :: (double colon) in Python when subscripting sequences?

I know that I can use something like string[3:4] to get a substring in Python, but what does the 3 mean …

python syntax slice
Python slice first and last element in list

Is there a way to slice only the first and last item in a list? For example; If this is …

python list slice subscript
How to return a part of an array in Ruby?

With a list in Python I can return a part of it using the following code: foo = [1,2,3,4,5,6] bar = [10,20,30,40,50,60] half = len(…

ruby arrays list slice
How to join a slice of strings into a single string?

package main import ( "fmt" "strings" ) func main() { reg := [...]string {"a","b","c"} fmt.Println(strings.Join(reg,",")) } gives me an …

go slice
How to replace values at specific indexes of a python list?

If I have a list: to_modify = [5,4,3,2,1,0] And then declare two other lists: indexes = [0,1,3,5] replacements = [0,0,0,0] How can I take to_…

python arrays slice