2,040 karma · joined January 4, 2011
[1] http://en.wikipedia.org/wiki/IEEE_floating_point#Exception_h...
> / 1 0
+Inf
Is not the correct answer - even as a limit - since the limit of 1 / x (when x -> 0) can be +Inf or -Inf.On Linux (and probably on other OSs) it's not easy to detect that the system is out heap memory because of lazy memory allocation policies.
Physical memory is not allocated when you call malloc() but when you first read or write the corresponding memory page.
Because of this, malloc() does not necessarily return NULL even if there isn't enough memory available on the system at the time you called malloc(). But if the system is still out of memory when your first access the allocated memory, your program will crash with a segfault.
So in absence of extra precaution, using heap memory isn't any safer than using stack memory.
Since I don't think anyone here would argue that "increment a by one" is a useful comment, the part about duplicate/obvious comments isn't adding much to the discussion about the usefulness of comments.
Nevertheless, it's true that comments cannot be checked by the compiler, and that's a more interesting point, I think.
-- swap the elements of a pair
swap :: (a,b) -> (b,a)
Yes this is redundant. let b=a+1 -- add one to 'a'
Yes this is also redundantDoes it mean that every piece of code can be expressed as clearly as in a one-line comment in natural language? I don't think so.
mplayer -vo aa video.mpg
Will use aalib to render video.mpg inside the current terminal/console.
The quality is not great though:
http://www.youtube.com/watch?v=O5JLjfCi0mw (Here with Vlc.)Ok, I agree.
>Like I said, you cannot quickly do better than a modern compiler, and a compiler does it very, very quick.
I'm not sure what you mean by "quickly" but this submission proves that it can be done in reasonable time. And if you look at the code (for example here: https://github.com/icebreaker/floppybird/blob/master/src/gam...), it's obvious that you cannot produce anything nearly as compact and efficient with a compiler.
So, claiming that assembly is still a language of choice nowadays was maybe exaggerated, nevertheless it's nice to remember that no matter how good they are, compilers come with a cost. If you need some evidence simply compare the submitted code with any code produced with a compiler.
This is a bit misleading, accesses to physical memory, disks and to other devices are usually protected by the operating system, not by the language. So you don't have direct hardware access because you program in assembly, but because you run a program without the control of an operating system. This can be done in assembly, but also in C or in any other language that can generate native code.
The only thing that you can do with assembly and that you can't really do with higher level language like C is accessing processor specific registers/instruction sets (e.g. SSE). And this is typically done using inline assembly snippets, as there is no reason to write a whole program in assembly when you only need to optimize a single function.
So I would say that having better hardware access is not a good reason to write an entire program in assembly.
On the other hand, building small, standalone executable file that use very little (stack) memory is still relevant for programs that run on very small (usually embedded) hardware. Especially when they need to run fast or to have low energy consumption. So speed and memory usage are still pretty good reasons to use assembly :)
It's not, in a closed system momentum is conserved [1] so without friction, a free engine would rotate forever.
Also there is not conceptual difference between an engine and a ball sniping in a donut. In both case, the piston or the ball have to change direction (the piston has to change direction more abruptly though)
I think we should stop trying to rationalize this choice.
Or rather, we should realize that we like text editors because we went through a long training and acquired complex skills which are fun to put in practice. Being a power user of Emacs or Vim is is satisfying, the same way mastering a video game is satisfying.
This submission is in itself, an elegant proof that sed is Turing complete.
These dummy tests can happen if you have a lot of macros for example. It still valid C code as long as p is not NULL. A compiler generating an error on this particular example wouldn't be a correct C compiler.
The compiler can reject this code if it can prove that p can be NULL, but in many case that's impossible at compile time.
I agree that a warning would be nice though.
edit: clarity.
If you know that p is not NULL, the code is just fine. The compiler has to compile it.
What does this mean? When employees are on strike, one solution is to increase wages. How is this a technical solution?
The good thing about astronomy is that there's always something impressive.
It's not just a mechanical engineering problem, the dynamic of the system is way too complex to be modeled with a simple formula. There's a lot of AI/machine learning involved in robotics. That's hard with or without external power supply.
That was a bit cheap but ok. Let me add more.
Here is the same data that I have reploted
This chart is less biased (y axis starts at 0) and the correlation is less obvious.
The correlation is actually -0.6557, which is significant but probably not as high as you would expect from the first chart. But ok the correlation between game software revenue and juvenile violence is probably here (we're talking about ~20 data points...). To go further and conclude anything about violent games, you would need at least the proportion of violent games among games, we don't have it here.
Here's the data that I've extracted from the pixel position. It's not 100% accurate, but it should be good enough.
1990 412.999995
1991 430.999995
1992 448.999995
1993 469.999995
1994 495.49999995
1995 487.99999995 3.2
1996 432.49999995 3.67407407407407
1997 384.49999995 3.74179894179894
1998 355.99999995 4.55449735449735
1999 322.99999995 5.43492063492064
2000 298.99999995 5.5026455026455
2001 291.49999995 5.90899470899471
2002 276.49999995 6.92486772486772
2003 285.49999995 7.06031746031746
2004 270.49999995 7.33121693121693
2005 279.49999995 6.92486772486772
2006 297.49999995 7.26349206349206
2007 286.99999995 9.43068783068783
2008 288.49999995 11.6656084656085
2009 261.49999995 16We could if it was a lab experiment where the only factor that varies would be the popularity of violent video games. But it's not.
It's entirely plausible the the increase of home entertainment has indeed reduced the rate of juvenile crimes. (kids don't stay in the street any more). Yet it doesn't say much about how violent games induce violent behaviours.
I haven't, I am not taf2. I was just saying that this inverse correlation that you see may be due to other factors or may not even be statistically significant. We're missing a lot of data here (e.g. how does the juvenile crimes rate fluctuates prior to 1990).
Yes that's my main point: this plot does not prove the correlation.
If you look at a bigger picture e.g. (maybe here [1], altough it's not technically the same metric) there was a peak around 94. The peak and the relative low value before the peak cannot be explained by video games.
And that my second point: no one ever claimed that violence is only caused by video games. Clearly the blue curve is under the influence of (many) other factors, so it's very hard to determine whether there is a correlation without knowing these other factors.
But let me say it once again, it's a possibility that video games reduce violence. I am simply saying that if think this is the case because of this plot, you're probably biased.
[1] http://www.eji.org/files/juv%20murder%20rate%20drop_0.jpg
But I still think that functional programming goes beyond simply specifying "what you want". Take the problem of sorting an array for example. A declarative specification of the sorting problem would be: Given an array T, compute a permutation of T such that for all i, it's true that T[i] < T[i+1] (some languages support this type of specification e.g. [1]).
Clearly here, you don't describe "how to do it". In functional programming you can't do this, you have to explain "how", implementing quicksort, for example.
This is not immediately obvious to me, here's why (from the same wikipedia article [1]):
While functional languages typically do appear to specify "how", a compiler for a purely functional programming language is free to extensively rewrite the operational behavior of a function, so long as the same result is returned for the same inputs. This can be used to, for example, make a function compute its result in parallel, or to perform substantial optimizations (such as deforestation) that a compiler may not be able to safely apply to a language with side effects.