That looks unbelievably complicated. Here's a nicer solution to the 1-100 problem (100-1 being very much the same, of course):
int printnums(int i) {
printf("%d\n", i);
(i < 100 ? printnums(i+1) : 0);
return i; }
int main(void) { printnums(1); return 0; }
You don't need to actually use the result of the ?: operator in order to use it as a control structure. (You do need to provide it with expressions which have the same type; this is why printnum() returns int and not void.) If ?: is too close to 'if', you can replace it with || or && and take advantage of their short-circuiting nature.
I think you're confusing operator precedence with the order of operations. Operators have a defined precedence, but operators which have side effects do not have a defined order in which their side effects are applied. Something like j = i++ * i++, if i = 1, could produce 1 or 2, depending on whether the increment in the first i++ is applied before or after the second i++ is evaluated. Either order would be acceptable behavior.
Is there a repository of these things lying around somewhere? I see them from time to time in different places, and they don't always seem to be the same.
Here's something that really confuses me: Libertarianism and anti-Environmentalism seem to go almost universally hand-in-hand.
One of the fundamentals of Libertarianism is private property rights. I should be allowed to fuck somebody in the ass as long as they consent and it's on my property. I should be allowed to drive a car at six times the speed limit as long as it's on my property. I should not be allowed to drive my car onto your property unless you agree to it.
So take a very simple extrapolation to environmental situations. I own a factory. I dump bizarre, toxic chemicals without any treatment. It's my property, so I should be able to do whatever I want. The same goes for driving an SUV, burying garbage, dumping mercury into my pond, whatever.
But the very instant that the pollution you emit gets onto somebody else's property, you're no longer in the right. When your toxic chemicals enter the ground water and leak into your neighbor's land, you're going beyond your rights. Even the staunchest Libertarian should agree that I should not have the right to contaminate the ground, water, or air on your property.
So for all of you wannabe Libertarians out there saying, "I have a right to drive a vehicle that gets as few miles per gallon and as many emissions as I feel like", answer me this: why do you have the right to contaminate the air I breathe on my property?
Us moderates simply don't bother to post in obviously stupid discussions like this one (your post excepted). Of course, this post is a paradox, but such is life.
It's not even that complicated. On most systems, you can atomically replace a single file with another, if both files are on the same filesystem. Given that, you can pretty easily save without the potential for destruction. Just save to a temporary file somewhere on the same filesystem as the real file. This can be just a backup file in the same directory. Once the save has completed, replace the original with the new one, and you're done.
If you don't have atomic replacement, either because you're on a filesystem or OS that doesn't support them, or because you need to replace directories, then you need to take a different approach. (I had to do this for an automatic update system that worked on entire directory trees; this is why I'm so utterly shocked that a FireFox autoupdate gone wrong can break the program.) In this case, you can save the file or directory next to the original, rename the original to something else, then rename the new version to the original name, and finally delete the original. There is a small window of time where no file with the right name exists, but both the old and new copies are there, they simply don't have the right name. At any given time, at least one of the copies is always complete and on-disk.
As another poster pointed out, this gets much more difficult when you have gigantic files, but it's easy for small files. On Mac OS X 10.2, I once ran out of disk space, and lost the preferences for about half of my applications. Apple's preferences system was saving files by deleting the old version and then writing the new version. Writing the new version failed because I was out of disk space, and so my setting just got flushed down the drain. Fortunately this is fixed, but it's a really horribly design bug to have.
So, not accepting multiple formats for the same data is bad. I have to ask why the multiple formats exist in the first place. If we're talking about SSN, library card number, etc. there's always an authority issuing these numbers. Why not use the same format they use, everywhere? If users want to be inconsistent, they must be prepared to deal with the consequences.
Come on, how hard is it to run your data through a filter that simply removes all dashes and spaces from the number? Not handling arbitrary inconsistency is understandable, but the number of web commerce sites out there that don't even allow spaces in your credit card number is unbelievable. Let me put spaces or dashes wherever I want, and remove them if you don't like them.
Also, if you don't keep the original file around until the new file is written, even with normal, user-prompted saves then you are the spawn of Satan! Overwriting the user's file directly is evil! Bad! Repeat after me: "If my software destroys the user's file in any circumstances, even if the power goes out in the middle of a write, or the IDE cable shorts out at the wrong instant, than my program is broken and needs to be fixed." All save operations should be atomic, not just automatic ones. Otherwise, you're just asking for trouble.
The problem is that there are actually two completely different kinds of support.
One kind is exactly what you describe. This is the "you can use whatever you want, but we won't help you unless you use the stuff we support" kind.
The other kind is much worse. It's the kind where they say, "You must use our application which only works from an administrator account running on Windows 2000 during the full moon. You cannot use anything else, because our protocols are 100% proprietary and no open alternative exists."
The sad thing is that many places don't distinguish between these types of support, forcing us to guess whether they just mean, "we won't help you", or whether they really mean, "you're totally screwed, go away".
The World Wide Web cannot exist in it's present form without the ability to link to anyone you choose. Take Slashdot as example. What if all the websites in these stories didn't want to be linked to? No more Slashdot.. Linking is the premise that the World Wide Web is built on.
This is basically the same argument the music companies are using. "Take BMI as an example. What if all of those customers chose to copy their music from their friends? No more BMI. Copyright is the premise that the music industry is built on." A much better argument would talk about how a link is just an address, which is public knowledge, and there is no law that prohibits dissemination of them.
820 pounds of TNT at 23,000 miles per hour produces an explosion equivalent to 5.4 tonnes of TNT. Most of this energy comes from the kinetic energy of the projectile, which is the same whether you use an explosive or a lump of metal, which was my entire point.
Could you please elaborate? I know it's fashionable to assume that Bush is evil incarnate, but everything he's done can be explained if he's caring, trying to do good, and simply incredibly stupid, incompetent, or ineffective. Why should I assume he's evil if there is no evidence of it? Do you have anything to back up this claim that my comment is naive?
Re:Expensive launch mass?
on
NASA's Deep Impact
·
· Score: 3, Insightful
The other 5 tons of TNT of explosion comes from the kinetic energy.
Re:Expensive launch mass?
on
NASA's Deep Impact
·
· Score: 5, Informative
The lump of copper is 820 pounds, and will be equivalent to 5 tons of TNT. If you sent an 820-pound lump of TNT, you would get an explosion of about 5.4 tons of TNT. An extra.4 tons-TNT increase, in exchange for a vastly more dangerous mission and chemical contamination is not a good trade.
At these speeds, the kinetic energy is so great that chemical explosives are nearly pointless.
Besides, Bush wants them in, so it cannot be right. He is probably hoping this to have a destabilizing and/or paralyzing influence on the entire EU...
Maybe he's just hoping that it will have a democratizing and modernizing influence on Turkey? I'm not a Bush fan, but Bush generally seems to have good intentions; it's just the implementation of his good intentions that he fucks over beyond belief.
It would be nice if it would actually scan for the things that aren't supported before popping up that notice, though. If you open a.doc, delete a letter, and hit save, you will get that notice, even though you can be pretty damned sure that nothing is going to be lost.
In general, standard of living is directly proportional to energy consumption. This may not hold completely true, and conservation may help. However, conservation tends to be on the order of saving 5% here, 10% there. Increases in energy usage, on the other hand, are often orders of magnitude. I want my standard of living to keep going up. The only way to stop demand from growing is to freeze everything the way it is today, and I don't like that idea at all.
One Apollo mission cost $110 billion in today's dollars (20 billion in 1970...)
I think you must have misread your source. According to the sources I can find, the entire Apollo program (including everything from Mercury on up, plus the robot missions) cost about $25 billion. As I recall, the incremental cost per flight was in the neighborhood of $500 million. (This last figure may be low; it seems to me that was the cost per Saturn V flight, not counting the cost of the "go to the moon" part of the mission.) It's also likely that the amount of material returned could be vastly more than 1/3 ton if the mission were designed around bulk transfer, rather than human survival and exploration equipment.
According to most pro-lifers I know, flushing an egg and sperm down the toilet five seconds before they meet up is just fine, but flushing them down the toilet five seconds after they meet is murdering a human life. Why is the line drawn at this point, and why is it so stark? It looks extremely arbitrary to me.
I think you're confusing operator precedence with the order of operations. Operators have a defined precedence, but operators which have side effects do not have a defined order in which their side effects are applied. Something like j = i++ * i++, if i = 1, could produce 1 or 2, depending on whether the increment in the first i++ is applied before or after the second i++ is evaluated. Either order would be acceptable behavior.
Is there a repository of these things lying around somewhere? I see them from time to time in different places, and they don't always seem to be the same.
And 9/11 was a result of some people who think we have the wrong imaginary friend. Which is worse?
Here's something that really confuses me: Libertarianism and anti-Environmentalism seem to go almost universally hand-in-hand.
One of the fundamentals of Libertarianism is private property rights. I should be allowed to fuck somebody in the ass as long as they consent and it's on my property. I should be allowed to drive a car at six times the speed limit as long as it's on my property. I should not be allowed to drive my car onto your property unless you agree to it.
So take a very simple extrapolation to environmental situations. I own a factory. I dump bizarre, toxic chemicals without any treatment. It's my property, so I should be able to do whatever I want. The same goes for driving an SUV, burying garbage, dumping mercury into my pond, whatever.
But the very instant that the pollution you emit gets onto somebody else's property, you're no longer in the right. When your toxic chemicals enter the ground water and leak into your neighbor's land, you're going beyond your rights. Even the staunchest Libertarian should agree that I should not have the right to contaminate the ground, water, or air on your property.
So for all of you wannabe Libertarians out there saying, "I have a right to drive a vehicle that gets as few miles per gallon and as many emissions as I feel like", answer me this: why do you have the right to contaminate the air I breathe on my property?
Us moderates simply don't bother to post in obviously stupid discussions like this one (your post excepted). Of course, this post is a paradox, but such is life.
Find out who's shooting who? Great idea. A highly-intelligent, ubiquitous, automated surveillance network? Not so great.
Gee, English has multiple past tenses. The curious thing about Choktaw isn't the quantity, it's what they're used for.
That's the whole problem with the profession. Lawyers generally cancel out, but we still have to pay for them.
It's not even that complicated. On most systems, you can atomically replace a single file with another, if both files are on the same filesystem. Given that, you can pretty easily save without the potential for destruction. Just save to a temporary file somewhere on the same filesystem as the real file. This can be just a backup file in the same directory. Once the save has completed, replace the original with the new one, and you're done.
If you don't have atomic replacement, either because you're on a filesystem or OS that doesn't support them, or because you need to replace directories, then you need to take a different approach. (I had to do this for an automatic update system that worked on entire directory trees; this is why I'm so utterly shocked that a FireFox autoupdate gone wrong can break the program.) In this case, you can save the file or directory next to the original, rename the original to something else, then rename the new version to the original name, and finally delete the original. There is a small window of time where no file with the right name exists, but both the old and new copies are there, they simply don't have the right name. At any given time, at least one of the copies is always complete and on-disk.
As another poster pointed out, this gets much more difficult when you have gigantic files, but it's easy for small files. On Mac OS X 10.2, I once ran out of disk space, and lost the preferences for about half of my applications. Apple's preferences system was saving files by deleting the old version and then writing the new version. Writing the new version failed because I was out of disk space, and so my setting just got flushed down the drain. Fortunately this is fixed, but it's a really horribly design bug to have.
Let's you save me some work
So, not accepting multiple formats for the same data is bad. I have to ask why the multiple formats exist in the first place. If we're talking about SSN, library card number, etc. there's always an authority issuing these numbers. Why not use the same format they use, everywhere? If users want to be inconsistent, they must be prepared to deal with the consequences.
Come on, how hard is it to run your data through a filter that simply removes all dashes and spaces from the number? Not handling arbitrary inconsistency is understandable, but the number of web commerce sites out there that don't even allow spaces in your credit card number is unbelievable. Let me put spaces or dashes wherever I want, and remove them if you don't like them.
Also, if you don't keep the original file around until the new file is written, even with normal, user-prompted saves then you are the spawn of Satan! Overwriting the user's file directly is evil! Bad! Repeat after me: "If my software destroys the user's file in any circumstances, even if the power goes out in the middle of a write, or the IDE cable shorts out at the wrong instant, than my program is broken and needs to be fixed." All save operations should be atomic, not just automatic ones. Otherwise, you're just asking for trouble.
The problem is that there are actually two completely different kinds of support.
One kind is exactly what you describe. This is the "you can use whatever you want, but we won't help you unless you use the stuff we support" kind.
The other kind is much worse. It's the kind where they say, "You must use our application which only works from an administrator account running on Windows 2000 during the full moon. You cannot use anything else, because our protocols are 100% proprietary and no open alternative exists."
The sad thing is that many places don't distinguish between these types of support, forcing us to guess whether they just mean, "we won't help you", or whether they really mean, "you're totally screwed, go away".
The World Wide Web cannot exist in it's present form without the ability to link to anyone you choose. Take Slashdot as example. What if all the websites in these stories didn't want to be linked to? No more Slashdot.. Linking is the premise that the World Wide Web is built on.
This is basically the same argument the music companies are using. "Take BMI as an example. What if all of those customers chose to copy their music from their friends? No more BMI. Copyright is the premise that the music industry is built on." A much better argument would talk about how a link is just an address, which is public knowledge, and there is no law that prohibits dissemination of them.
Wake up, engage brain.
820 pounds of TNT at 23,000 miles per hour produces an explosion equivalent to 5.4 tonnes of TNT. Most of this energy comes from the kinetic energy of the projectile, which is the same whether you use an explosive or a lump of metal, which was my entire point.
I think the policy is weird too, but in the military's defense, thieves and wifebeaters are probably more effective soldiers than potheads.
Please, we are "people", not "consumers". You're using the language of the oppressors.
Could you please elaborate? I know it's fashionable to assume that Bush is evil incarnate, but everything he's done can be explained if he's caring, trying to do good, and simply incredibly stupid, incompetent, or ineffective. Why should I assume he's evil if there is no evidence of it? Do you have anything to back up this claim that my comment is naive?
The other 5 tons of TNT of explosion comes from the kinetic energy.
The lump of copper is 820 pounds, and will be equivalent to 5 tons of TNT. If you sent an 820-pound lump of TNT, you would get an explosion of about 5.4 tons of TNT. An extra .4 tons-TNT increase, in exchange for a vastly more dangerous mission and chemical contamination is not a good trade.
At these speeds, the kinetic energy is so great that chemical explosives are nearly pointless.
Besides, Bush wants them in, so it cannot be right. He is probably hoping this to have a destabilizing and/or paralyzing influence on the entire EU...
Maybe he's just hoping that it will have a democratizing and modernizing influence on Turkey? I'm not a Bush fan, but Bush generally seems to have good intentions; it's just the implementation of his good intentions that he fucks over beyond belief.
It would be nice if it would actually scan for the things that aren't supported before popping up that notice, though. If you open a .doc, delete a letter, and hit save, you will get that notice, even though you can be pretty damned sure that nothing is going to be lost.
In general, standard of living is directly proportional to energy consumption. This may not hold completely true, and conservation may help. However, conservation tends to be on the order of saving 5% here, 10% there. Increases in energy usage, on the other hand, are often orders of magnitude. I want my standard of living to keep going up. The only way to stop demand from growing is to freeze everything the way it is today, and I don't like that idea at all.
One Apollo mission cost $110 billion in today's dollars (20 billion in 1970...)
I think you must have misread your source. According to the sources I can find, the entire Apollo program (including everything from Mercury on up, plus the robot missions) cost about $25 billion. As I recall, the incremental cost per flight was in the neighborhood of $500 million. (This last figure may be low; it seems to me that was the cost per Saturn V flight, not counting the cost of the "go to the moon" part of the mission.) It's also likely that the amount of material returned could be vastly more than 1/3 ton if the mission were designed around bulk transfer, rather than human survival and exploration equipment.
According to most pro-lifers I know, flushing an egg and sperm down the toilet five seconds before they meet up is just fine, but flushing them down the toilet five seconds after they meet is murdering a human life. Why is the line drawn at this point, and why is it so stark? It looks extremely arbitrary to me.