Progrider

Programming discussion

Recent posts

The newest topics and replies across all categories.

PostPosted
General · post #9

Pascal in school. We made program for the school library, to track who has which book. Librarian used it three years until the computer died. I think nobody made backup.


by tomasz
Help · post #13

Same two pass thing applies in numpy, compute everything from the old array then assign. Learned that from a very wrong heat diffusion plot.


by lena_w
Findings · post #1

Lost an evening to this. Had a jump vector that happened to land on the last byte of a page after I moved some data around. JMP ($30FF) reads the low byte from $30FF and the high byte from $3000, not …


by zp_indirect
Help · post #12

Oh. That was a bug I had and didn't know. Thank you.


by tomasz
General · post #8

at least you got paid


by vek
Help · post #11

For pairs from two separate halves, yes. For all pairs like you have, it just makes it harder to read. If you need to update both at once then split_at_mut, or swap to computing a list of deltas in on…


by ferrous
General · post #7

Java, sadly, and I've been paying for it since.


by gcfail
Help · post #10

It works. There is also split_at_mut in documentation, is that better?


by tomasz
Help · post #5

ok worked ty


by pbj
Help · post #4

Run it with -print before -delete the first time. -delete does what it says and there's no bin.


by lintroller
Help · post #3

And if you do want xargs for something other than deleting, use find -print0 | xargs -0, then spaces and newlines in names are fine. Or find ... -exec cmd {} + which does the same batching with no pip…


by awkward
Help · post #2

find . -name '*.log' -delete Quote the pattern, or your shell expands it before find sees it. If you've got one .log in the current dir you're searching for that one exact name.


by vek
Help · post #1

find . -name *.log | xargs rm says no such file for some of them. how do i fix


by pbj
Help · post #9

vek is right in spirit, you do end up reinventing handles and arenas. Though that's how a lot of good C ended up as well.


by carcdr
Help · post #8

"Rewrite it in Rust" -> rewrites it in array indices, like Fortran


by vek
Help · post #7

Indices, usually. for i in 0..particles.len() { for j in 0..particles.len() { if i == j { continue; } let d = particles[j].pos - particles[i].pos; particles[i].vel += d * k; } } Each indexing is a sho…


by ferrous
Help · post #6

Next problem then. My real code is a list of particles, and each one should look at its neighbours and change itself. for p in particles.iter_mut() { for q in particles.iter() { ... } } Same error of …


by tomasz
Help · post #5

Yes. Non-lexical lifetimes. The borrow lasts until the last use.


by ferrous
Help · post #4

OK this makes sense. But if I swap the last two lines it compiles. So the borrow ends at the last use and not at end of the block?


by tomasz
Help · post #3

Can confirm the C++ part, I have the scars.


by jf
Help · post #2

push might reallocate. If the Vec is at capacity it allocates a bigger buffer, moves everything and frees the old one. Then first points at freed memory. The borrow checker doesn't know whether this p…


by ferrous
Help · post #1

I learn Rust since two weeks. This does not compile: let mut v = vec![1, 2, 3]; let first = &v[0]; v.push(4); println!("{}", first); error[E0502]: cannot borrow `v` as mutable because it is also borro…


by tomasz
General · post #6

6502 assembly via a C64 monitor, because BASIC was too slow for the sprite routine I wanted. It wasn't useful as such, but it was useful to me


by zp_indirect
General · post #5

I'm still working on this one to be honest! Started Python last year to help with marking. The first thing that actually saved me time was a script that renames the scanned worksheets using the class …


by bea
Help · post #4

That fixed it, thanks both! José is back.


by bea
All times shown in UTC.