356 karma · joined Jun 5, 2015 (11y ago) · 72 submissions
comment 4y ago · link · parent
It works better with the modulo operator: `array[i%length]` vs `array[(i+length-1)%length+1]`. Or you would have to define a modulo-like operator that maps ℕ to [1..n].
It works better if you have a multi-dimensional index, for example the pixels in an image. With 0 based indexing, pixel `(x,y)` is at `array[x+widthy]`. With 1 based indexing it is at `array[x+width(y-1)]`. You might argue that programming languages should support multi-dimensional arrays, but you still need operations like resizing, views, etc.
comment 4y ago · link · parent
Another problem is that a data structure's invariant can depend on the trait implementation. For example a tree is balanced with a comparison. This means that the comparison has to be stored in the struct, with the corresponding runtime overhead. With traits you know that there is only a single implementation for any particular type, so if the trait v-table is an argument to every method call there is no risk of different implementations being used at different times.
comment 5y ago · link · parent
comment 5y ago · link · parent
Low-level optimization can be worth it:
* You can try to pack the game state into integers and use bitwise operations. An 8×8 board can be stored as a 64 bit vector, so a `u64`. If you know the edges of the board are never occupied, then moving around can be as simple as a bit shift (probably not for this game).
* A smaller state representation also means that HashMap lookups will be faster.
* Instead of using a pair of integers to represent a position, use a single integer and save a multiplication for every lookup into a grid.
* Add a ring of impassible cells around the board, instead of checking for the edges of the board each time.
comment 5y ago · link · parent
comment 5y ago · link · parent
If solar+batteries can outcompete fossil fuel plants (while ignoring fuel costs), then fusion likely wouldn't be viable commercially. And if you look at [the data](https://en.wikipedia.org/wiki/Cost_of_electricity_by_source#...), we are already close to this point.
comment 5y ago · link · parent
comment 5y ago · link · parent
I would write something like this in haskell:
spec :: [Integer] -> Property
spec xs =
length xs <= 2 ==> fun (intercalate "," (map show xs)) == sum xs
This captures the three requirements, but not the implicit fourth requirement that the function throws an exception for other inputs.comment 6y ago · link · parent
Most of these references talk about how there is no clear benefit of vegetable oils over animal oils or how "chronic canola oil consumption" results in obesity in transgenic mice. That is not really the same thing as "growing evidence for the harms of canola oil".
comment 6y ago · link · parent
Isn't that the delta-v needed to reach a stable orbit? That is, to slow down and counteract all the kinetic energy you gained from the sun's gravity. To just hit the sun (with high velocity) you wouldn't need to do that.
comment 6y ago · link · parent
That is not true. The tensile strength of kevlar and dynema is higher than that of steel, while they have a density that is several times lower.
comment 6y ago · link · parent
comment 6y ago · link · parent
comment 7y ago · link · parent
However, you are right in saying that this violates the GDPR, because the data was collected for a different purpose, and using it for another reason like advertising is not allowed.
comment 7y ago · link · parent
If charity1 has a 20% overhead and then spends the rest on saving the life of a child for every 1000$, while charity2 has a 40% overhead but saves a child for every remaining 500$ spent, which one is better? Overhead is just one factor of a charity's efficiency.
Of course in this case the cost of the powder is just a small factor, and you also need to consider the cost of distribution and other overheads. And the fact that the effectiveness probably drops off at some point. Obviously just spending 1B$ is not going to save 20 billion children, there aren't that many children that need these ORS packets.
comment 7y ago · link · parent
I think it means that if you opt out of data collection, then things like personalized recommendations will no longer work, which makes the services worse. That is a part of the service directly related to the data.
comment 7y ago · link · parent
There are actually several things that reference the stack. For example the reminder text for Split second ("As long as this spell is on the stack, players can't cast spells or activate abilities that aren't mana abilities.") and end the turn ("Exile all spells and abilities from the stack, including this card..."). From this we learn that normally people can cast spells and abilities, and that these go onto "the stack". And if you know what a stack is, then the resolution order follows from that.