6,359 questions
0
votes
3
answers
90
views
How to slice first char from all iterable records in a string (converted from list)
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 ...
-2
votes
2
answers
114
views
Slice the extension `'.txt'` from file names [duplicate]
I was trying to slice the extension '.txt' from some file names.
It look like the Python cut the last letter - before the dot- if its a t or x:
filenames = ["report.txt", "downloads....
3
votes
1
answer
120
views
Sequence association vs. modern Fortran interfaces
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, ...
0
votes
1
answer
42
views
Get image to actually tile in storyboard same as it does for SwiftUI [duplicate]
So I have this code in SwiftUI, it's working great.
.background(
Image("felt")
.resizable(resizingMode: .tile)
...
0
votes
0
answers
61
views
Index reference by None in Python [duplicate]
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 ...
3
votes
1
answer
160
views
How is range over slices.All() different from just range over a slice?
In the Go Tour we have
var pow = []int{1, 2, 4, 8, 16, 32, 64, 128}
func main() {
for i, v := range pow {
fmt.Printf("2**%d = %d\n", i, v)
}
}
which outputs:
2**0 = 1
2**1 ...
5
votes
2
answers
146
views
Performance of list.extend slice vs islice
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 ...
0
votes
3
answers
118
views
: slice keeps cutting off the third+ digit. Why? How do I fix this? [closed]
I have an assignment that I am working on in Python, where I can only slice using the : slice method (e.g. group= strg [:index]). For some reason, slice refuses to see anything past 2 digits when it's ...
1
vote
1
answer
65
views
How to display 3 elements by 3 of an array in HTML using array.sclice() method in javascript
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 ...
3
votes
1
answer
108
views
How does Rust know how big any of the smart pointer types are supposed to be?
In the following Rust code, a Box or Rc containing a u32 is 8 bytes, while a Box or Rc containing a slice is 16 bytes. I understand why this is; a smart pointer pointing to a dynamically sized area of ...
0
votes
2
answers
89
views
Unexpected behavior with array slicing and mask
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
>>&...
1
vote
1
answer
119
views
How do I use Arc with interior mutability over slices?
MRE:
use std::sync::Arc;
use std::thread;
fn main() {
let arr1 = Arc::new(vec![10; 100]);
let arr2 = Arc::new(vec![20; 100]);
let arr3 = Arc::new(vec![00; 100]); // Going to need interior ...
0
votes
0
answers
36
views
Texture Slicing for displaying pseudo 3D planes in XNA/Monogame
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()
{
...
2
votes
2
answers
143
views
What the efficiency of using "one allocation" realization of 2D slices?
I'm learning the Go and now I've reached the point of studying arrays and slices. I'm referring to Effective Go and A Tour of Go in this question. I have some doubts in the formulation of slice's ...
1
vote
1
answer
82
views
How do I move as many elements as possible from a Vec into a pre-existing slice?
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 ...