Questions tagged [slice]
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. Please use the tags "object-slicing" for the slicing problem in C++ and "program-slicing" for the analysis technique.
slice
6,326
questions
1
vote
1
answer
45
views
how to add all thing in slice to a only one string
hello every body i was coding about create a map and on that map we have 2 thing name of book and number of book and i stuck in one thing if name of book is look like this "Harry Potter" ...
2
votes
1
answer
51
views
javascript setting a .map() range and update the range later
I'm building an app with React & JS which returns products from a json list inside a component, the array is outputted on the app using a .map() array. I'm also limiting the amount to return ...
1
vote
1
answer
88
views
multidimensional slice access performance in golang
I am working on a little and simple game-of-life in Golang and stumbled on a performance problem during slice access.
This is the primary data structure for the game:
type Neighbor struct {
X, Y ...
-1
votes
1
answer
44
views
capacity of Go slices [duplicate]
Why cap(b) is 6 shouldn't be 5?
package main
import "fmt"
func main() {
var s []int
a := append(s, 1, 2, 3, 4)
b := append(s, 1, 2, 3, 4, 5)
c := append(s, 1, 2, 3, 4, 5, 6)
...
1
vote
1
answer
29
views
Django reversed for loop slice
I am currently trying to reverse a slice of a list going from 0 to 11
class Game(models.Model):
board = models.JSONField(default=list)
game = Game(board=[4] * 12, scores=[0, 0], current_player=0, ...
0
votes
3
answers
57
views
Slice row out of CSV file using either Python alone or jsonata
I am using the C2Intel Feeds to find specific observables and when I do, I'd like to extract/slice out the row.
Example:
https://raw.githubusercontent.com/drb-ra/C2IntelFeeds/master/feeds/...
0
votes
1
answer
57
views
GoLang - looping through array of structs - can I map?
I'm new to GoLang, coming from Node. A little late to the (definitely not functional) game and need some help understanding approaches, and perhaps just understanding...
I want to omit an item from a ...
-2
votes
0
answers
31
views
Extract Month from time column 2024-06-30 [duplicate]
I have a data frame in using the R language with a "date" column YYYY-MM-DD and I want to extract the month and create a new column in my data frame named "month" with just the ...
3
votes
1
answer
57
views
Slicing multiple chunks in a polars dataframe
Consider the following dataframe.
df = pl.DataFrame(data={"col1": range(10)})
┌──────┐
│ col1 │
│ --- │
│ i64 │
╞══════╡
│ 0 │
│ 1 │
│ 2 │
│ 3 │
│ 4 │
│ 5 │
│ 6 │
│ 7 ...
-1
votes
1
answer
64
views
Dereferencing pointers in a slice does not seem to yield the initial value that the pointer was created from [duplicate]
I need to make a slice of pointers for a Go project I'm working on, that references the items in a slice. The expected behavior would be that I could modify one of the dereferenced items in the slice ...
0
votes
1
answer
96
views
How to initialize a mutable array in Zig?
I've been working through ziglings, and in the last exercise (#107) I have to initialize a slice to a 64 character array filled with 'A's. This much is fine. The issue is that the values have to be ...
-2
votes
3
answers
156
views
Is there a Numpy function to subset an array based on values (not indices) in a slice or range?
I am trying to extract, from an array, all values within a certain slice (something like a range, but with optional start, stop and step). And in that, I want to benefit from the heavy optimizations ...
-3
votes
2
answers
72
views
How to remove duplicate elements from a slice of slices in golang
i have a function which returns a slice of slices.
[[-1 -1 2] [-1 0 1] [-1 0 1]]
Trying one way of map method wont work because slice cannot be a key. How do i remove the duplicate elements here.
1
vote
3
answers
71
views
slicing the last letter of a string in python while having both a start and stop-value?
Is it possible to slice the last letter of a string in python while still having stop-value? I would like to create a loop to slice all the letters of a string individually from the back to the front, ...
1
vote
1
answer
36
views
Slice of Strings Operation Reports System.Object Array Conversion Error
When attempting to replace values in a slice of a string array I am getting this error
Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System....