Skip to main content
The 2024 Developer Survey results are live! See the results

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
1 vote
1 answer
45 views

A compilation error while using builtin func "max" with Go 1.22.1 : "invalid operation: invalid use of ... with built-in max"

I want to use max to get the maximum in slice, and I looked at the function declaration for max: func max[T cmp.Ordered](x T, y ...T) T But even though it was the same as my "myMax" ...
haha wa's user avatar
  • 21
0 votes
3 answers
70 views

Golang map value modifed after append [duplicate]

Can someone explain why my struct's value "Name" is altered after it was appended to a new slice? package main import ( "fmt" "strings" "golang.org/x/...
stego's user avatar
  • 203
1 vote
2 answers
52 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" ...
Sepehr's user avatar
  • 21
2 votes
1 answer
55 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 ...
Chobbit's user avatar
  • 493
1 vote
1 answer
93 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 ...
Tom's user avatar
  • 119
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, ...
trexgris's user avatar
  • 390
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/...
SergeT's user avatar
  • 15
0 votes
1 answer
60 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 ...
Harry Lincoln's user avatar
-2 votes
0 answers
32 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 ...
Jon Bellino's user avatar
3 votes
1 answer
62 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 ...
Andi's user avatar
  • 4,011
-1 votes
1 answer
68 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 ...
kanennn's user avatar
  • 44
0 votes
1 answer
115 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 ...
Karvie's user avatar
  • 3
-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 ...
bers's user avatar
  • 5,385
-3 votes
2 answers
76 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.
chetan honnavile's user avatar
1 vote
3 answers
72 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, ...
Archangel071's user avatar

15 30 50 per page
1
2 3 4 5
422