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.

Python: how to slice a dictionary based on the values of its keys?

Say I have a dictionary built like this: d={0:1, 1:2, 2:3, 10:4, 11:5, 12:6, 100:7, 101:8, 102:9, 200:10, 201:11, 202:12} and I want to create a subdictionary d1 by slicing d …

python dictionary key slice hashable
Golang: convert slices into map

Is there an easy/simple means of converting a slice into a map in Golang? Like converting an array into …

go maps slice
Slice chunking in Go

I have a slice with ~2.1 million log strings in it, and I would like to create a slice of slices …

go slice chunking
Python reverse-stride slicing

A specific example of my question is, "How can I get '3210' in this example?" >>> foo = …

python string slice
How to prepend int to slice

I am fairly new to Go and thus my question might seem a bit naive. I have a slice which …

arrays go slice prepend
In Swift, what's the cleanest way to get the last two items in an Array?

Is there a cleaner way to get the last two items of an array in Swift? In general, I try …

arrays swift slice
How to extract an arbitrary line of values from a numpy array?

I have a numpy array that contains some image data. I would like to plot the 'profile' of a transect …

python numpy indexing slice
Slicing a list using a variable, in Python

Given a list a = range(10) You can slice it using statements such as a[1] a[2:4] However, I want to do …

python list slice
Array and slice data types

I found myself confused with the array and slice data types. From Go docs, arrays are described as follows: There …

arrays go slice pass-by-value func
Difference between list, sequence and slice in Python?

What are the differences between these built-in Python data types: list, sequence and slice? As I see it, all three …

python list definition sequence slice