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.

A slice is a representation of a part of a sequence (including, but not limited to, lists, arrays and strings), 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.

Further reading:

6208 questions
2
votes
1 answer

Create variable of unique combinations based on condition in R

in the following dataframe structure(list(model = c("A1", "A1", "B4", "B4", "B4", "A4", "A4", "A4", "G4", "G4"), category = c("X", "Y", "X", "Y", "Z", "X", "Y", "Z", "X", "Z"), sale = c(194L, 0L, 59L, 29L, 0L, 176L, 88L, 0L, 87L, 44L)), class =…
Mark Noble
  • 21
  • 2
2
votes
4 answers

Slice An Array Of Files In A Change Event Listener, When The Total Allowed Number Of Files Is Added In More Than One Go - JavaScript

I have a form that takes file uploads and it currently has a limit of 10 files per upload. There are PHP validations in the backend for this too. When more than 10 files are attached, I currently have a JavaScript slice(0, 10) method inside a change…
paulo77
  • 174
  • 14
2
votes
1 answer

How to add new elements of a slice automatically to function parameter as slice grows

Is there a way to doing this automatically ? package main import "fmt" func main() { var a []string a = append(a, "this", "this2", "this3") increaseArguments(a) a = append(a, "this4") increaseArguments(a) } func…
user18572278
2
votes
2 answers

File Names Chain in python

I CANNOT USE ANY IMPORTED LIBRARY. I have this task where I have some directories containing some files; every file contains, besides some words, the name of the next file to be opened, in its first line. Once every word of every files contained in…
youngsoyuz
  • 23
  • 5
2
votes
1 answer

Does taking the address of a slice element implies a copy of the element in Go?

Let's say a Go 1.18 program has a quite heavy struct, for which copying is to be considered costly: type MyStruct struct { P string // a lot of properties } Now let's define a function, taking a slice of such elements as input parameter,…
A. Gille
  • 912
  • 6
  • 23
2
votes
1 answer

Slice dataframe based on last row valuse

I would like to slice a dataframe so, that I output only columns where values in the last row (or at a certain index) are bigger than a certain criterion. Example: The dataframe: Name T TU TUXT TEXT TEST Date …
Dmitry
  • 145
  • 9
2
votes
1 answer

How to cast a uint32 array to a uint8 array in Golang (Basically convert this statement from C to Golang)?

Hey guys I have trouble converting this statement below in C to Golang. I tried debugging and I see that every 4th element in the char array is being modified and the statement is casting a char to an unsigned int so that the OR operation can take…
zahid kamil
  • 165
  • 6
2
votes
2 answers

gcloud functions deploy go runtime error "undefined: unsafe.Slice; Error ID: 2f5e35a0"

While deploying to google cloud function, I am getting this error: ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: #…
2
votes
1 answer

Idiomatic way in Rust to dump slice contents onto an array?

I was doing something like this: type HashId = [u8; 32]; fn fill_hash_id(hash_id: &mut HashId, hash_data: &[u8]) { for i in 0..32 { hash_id[i] = hash_data[i]; } () } Is there a better, more direct or idiomatic way for this in…
2
votes
1 answer

Python array: Take two and skip two

I have a case where I have input array like this below array([[[ 1., 0., 2., 0., 3., 0., 4., 0., 5.], [ 6., 0., 7., 0., 8., 0., 9., 0., 10.], [11., 0., 12., 0., 13., 0., 14., 0., 15.]], [[16., 0., 17., …
2
votes
5 answers

Lock slice before reading and modifying it

My experience working with Go is recent and in reviewing some code, I have seen that while it is write-protected, there is a problem with reading the data. Not with the reading itself, but with possible modifications that can occur between the…
devOps
  • 114
  • 8
2
votes
1 answer

How to print multiple slices as one slice?

In this Golang code, I have a variable called developers which is equal to two slices. I want them to be equal to one slice as shown in the required result. Although I could do it by writing it in a single slice like this {"first developer", "second…
2
votes
3 answers

Slice an array index wise and push into empty array

I have 2 arrays. one of them(config) decides how many elements are going to be pushed in new array(finalData) from existing array(items). I tried to use slice but at the 3rd index the value is duplicated from the 2nd index. Try to run code and…
Chandler Bing
  • 410
  • 5
  • 25
2
votes
1 answer

Query MongoDb collection regarding an array of objects in a Go project

In a Go project I stored some data like this in a MongoDb Collection: { _id:ObjectId("631f0752da589137a71687f6"), target: { roomId: '11' } } { _id:ObjectId("43150752da589137a71687f6"), target: { roomId: '12' } } . . . I have a…
Fcoder
  • 9,066
  • 17
  • 63
  • 100
2
votes
1 answer

Find overlapping or inserted rows in python

I have a simple DataFrame: start end 0 30 40 1 45 55 2 50 60 3 53 64 4 65 70 5 75 80 6 77 85 7 80 83 8 90 120 9 95 100 10 105 110 You may notice some rows are part of…
Keyreall
  • 97
  • 1
  • 5