Skip to main content
Filter by
Sorted by
Tagged with
Best practices
0 votes
3 replies
92 views

If I define a slice as follows then it will have a length of 0 and a capacity of 10: var logs = make([]string, 0, 10) After appending data to this slice, I check to see if it is at capacity and if it ...
chrixm's user avatar
  • 1,034
0 votes
3 answers
111 views

I'm trying to remove the first/last two characters of each iterable record in a string (which I converted from a list and split into separate lines). newString = "\n".join([str(item) for ...
Python Journeyman's user avatar
3 votes
1 answer
128 views

Consider the following (traditional) Fortran code, which performs matrix-vector multiplication z = X y, but instead of the full matrix, we exclude the top two rows: subroutine matrix_vector_product(m, ...
summentier's user avatar
0 votes
0 answers
62 views

I am currently trying out slicing a string in Python and was confused about how exactly does Python interpret the term 'None' because it behaves rather conveniently when used but I am not how does it ...
Shreyas's user avatar
  • 11
5 votes
2 answers
160 views

It seems that even when islice would theoretically be better, in practice, it is slower than just using slice. So I am a bit puzzled by the difference in performance between the usage of slice and ...
Mathias Sven's user avatar
1 vote
1 answer
67 views

I have found a way to display a portion of an array using arrayName.slice(start, end), i made a funtion to feed the start and end to the slice method so i can use it with onClick button to click next ...
elbannhawy's user avatar
0 votes
2 answers
94 views

It was unexpected that x=np.empty((2,10,5)) x.shape >>> (2, 10, 5) x[0].shape, x[0,:,:].shape >>> ((10, 5), (10, 5)) mask = [True,True,True,False,False] x[0,:,mask].shape >>&...
pas-calc's user avatar
  • 170
0 votes
0 answers
39 views

currently I'm drawing pseudo 3D road segments to achieve a fake 3D road by drawing lines. This is what it looks like: The road is also moving smoothly. Here is my code: public void Draw() { ...
Canox's user avatar
  • 569
1 vote
1 answer
89 views

I have src: Vec<Foo> and dst: &mut [Foo]. I want to move as many elements as possible from src into dst. Specifically: If src is shorter than dst, then the beginning of dst should be ...
Joseph Sible-Reinstate Monica's user avatar
0 votes
1 answer
222 views

While trying to implement resource limitation (Debian 12) for all users except root user i faced that user-0.slice MemoryMax does not override user.slice MemoryMax parameter. root@:/etc/systemd/system....
Ignatella's user avatar
3 votes
1 answer
113 views

In a recent post Pandas performance while iterating a state vector, I noticed a performance when slicing pandas dataframes that i do not understand. The code presented here does not do anything ...
user1573820's user avatar
1 vote
1 answer
87 views

Scenario is a game with lots of units placed on a map (tilemap). Some of this units belonging to different empires fight against each other. Approach was to create a slice of pointers to units to be ...
scratch's user avatar
  • 164
-1 votes
1 answer
119 views

I want to serialize data into a buffer, but not starting at the first byte, so I tried passing a slice to the serializer. The serializer works if you pass the whole Vec like this: let mut buffer = Vec:...
bikeman868's user avatar
  • 2,685
1 vote
2 answers
111 views

With m := map[string]any{"a": 1, "b": 2, "c": []int{2, 3, 4}} v := reflect.ValueOf(m) How to iterate through "c" in v? See https://go.dev/play/p/...
xpt's user avatar
  • 23.6k
1 vote
1 answer
748 views

What JavaScript API should I look for if I want to read a File (e.g. from an <input type="file" ...> or a drop area) in chunks and upload these chunks sequentially - but without ...
MrSnrub's user avatar
  • 1,255
-1 votes
4 answers
76 views

I have an array with following elements: $array = ["START","a","a","a","START","b","b","b","START","c&...
ConDentures's user avatar
1 vote
1 answer
74 views

I am trying to run this code snippet: test="test" print(test[3:-1:-1]) For the slicing, the start index should start from 3 which is inclusive and stop index should be -1 exclusive which ...
kiran kumar's user avatar
1 vote
2 answers
153 views

To be more specific, I'm wondering how to assign a tensor by slice and by mask at different dimension(s) simultaneously in PyTorch. Here's a small example about what I want to do: With the tensors and ...
LibrarristShalinward's user avatar
4 votes
1 answer
127 views

Would it be possible given an array A, bad row indices and bad column indices to use slicing to make a new array that does not have these rows or columns? This can be done with np.delete as follows: ...
KyroHere's user avatar
4 votes
1 answer
130 views

I have a data structure where conceptually, I have a sequence of tuples of integers, all of the same size. However, this size is not known at compile time, so I can't use actual tuples or arrays or ...
Erik P.'s user avatar
  • 1,637
2 votes
1 answer
991 views

I want to sort a fruit list alphabetically in ascending order: const allocator = std.heap.page_allocator; var list = std.ArrayList([]const u8).init(allocator); defer list.deinit(); try list.append(&...
wchmb's user avatar
  • 1,363
1 vote
1 answer
117 views

I have a struct like: type Foo string type Mystruct struct { currentFoo Foo foos []Foo } I want to validate that currentFoo is in foos. I am doing func (s MyStruct) ValidateInput() error { ...
bcsta's user avatar
  • 2,377
1 vote
1 answer
117 views

I want to do something along the lines of... import numpy as np arr = np.linspace(0, 10, 100) s = slice(1, 10) print(arr[s]) print(arr[~s]) How could I apply the "not" operator to a slice, ...
Tom McLean's user avatar
  • 6,633
-3 votes
1 answer
126 views

i have a small question about 'append' function in golang: I have a slice1 and a function which calls in for loop and returns some slice2 which can be empty as well. So the question is how golang will ...
MaksimFeed's user avatar
-1 votes
1 answer
163 views

I have a VHDL entity with some unconstrained std_logic_vector ports that is wrapped by a verilog module that clearly defines those port widths. Verilog wrapper: module conv_wrapper (din,dout,clk,ce); ...
Fo0ty's user avatar
  • 31

1
2 3 4 5
128