Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on How I See Numbers. Parent comment
Sometimes the domain is already graphical - and I take every opportunity to make the code match the visual layout, ex:
https://github.com/danthedaniel/gameoflife-rs/blob/master/sr...
/// Count living cells adjacent to a cell in the matrix. #[inline] #[rustfmt::skip] fn alive_neighbors(&self, x: i32, y: i32) -> u8 { [ self[(x - 1, y - 1)], self[(x + 0, y - 1)], self[(x + 1, y - 1)], self[(x - 1, y + 0)], /* selected cell */ self[(x + 1, y + 0)], self[(x - 1, y + 1)], self[(x + 0, y + 1)], self[(x + 1, y + 1)], ] .iter() .fold(0, |total, &neighbor| total + (neighbor != 0) as u8) }
There are no comments on this comment yet.
Sometimes the domain is already graphical - and I take every opportunity to make the code match the visual layout, ex:
https://github.com/danthedaniel/gameoflife-rs/blob/master/sr...