Why would a language NOT use Short-circuit evaluation? Are there any benefits of not using it?
I see that it could lead to some performances issues... is that true? Why?
Related question : Benefits of using short-circuit evaluation
...
I'm aware that fold-left produces left-leaning trees and fold-right produces right-leaning trees, but when I reach for a fold, I sometimes find myself getting bogged down in headache-inducing thought trying to determine which kind of fold is appropriate. I usually end up unwinding the entire problem and stepping through the implementati...
I've done a lot of relatively simple numerical programming, and a large amount of programming in general. In that time, I've found that a lot of people tend to perform what I call optimization by suspicion, or optimization by hearsay. Some of these really are optimizations (and indeed, some of them make a significant difference in actual...
from Wikipedia:
Lexicographical order generation
For every number k, with 0 ≤ k < n!,
the following algorithm generates the
corresponding lexicographical
permutation of the initial sequence
sj, j = 1, ..., n:
function permutation(k, s) {
var int n:= length(s); factorial:= 1;
for j= 2 to n- 1 { // compu...
EDIT 2009-Nov-04
OK, so it's been a little while since I first posted this question. It seems to me that many of the initial responders failed to really get what I was saying--a common response was some variation on "What you're saying doesn't make any sense"--and so I've made some handy diagrams to really illustrate my point.
When we ...
I'm a complete beginner, and this is how I understand linking: Static linking copies only the code that is actually used into the executable. Dynamic linking uses .dlls that may contain a lot of code that is never used by the application. Please correct me if I'm wrong :)
Now here's my question. I'm using an open source library in my ap...
Hi,
I learnt that by default I/O in programs is buffered, i.e they are served from a temporary storage to the requesting program.
I understand that buffering improves IO performance (may be by reducing system calls).
An explanation on this will also help.
Also I have seen functions say in C setvbuf to enable/disable buffering.
I wanted ...
Many modern programming languages allow us to handle potentially infinite lists and to perform certain operations on them.
Example [Python]:
EvenSquareNumbers = ( x * x for x in naturals() if x mod 2 == 0 )
Such lists can exist because only elements that are actually required are computed. (Lazy evaluation)
I just wondered out of in...
If I have a set of values (which I'll call x), and a number of subsets of x:
What is the best way to work out all possible combinations of subsets whose union is equal to x, but none of whom intersect with each other.
An example might be:
if x is the set of the numbers 1 to 100, and I have four subsets:
a = 0-49
b = 50-100
c = 50-75...
Some popular programming languages use month numbering which is off by 1 -- JavaScript comes to mind, as does Java, and if memory serves, C is another. I have some questions:
If you are going to be ignoring the month numbering used by laypeople, then why not for the sake of consistency also ignore the day numbering used by laypeople, a...
Searching for a free application for commercial usage that allows find/replace in multiple files (regular expressions are nice but not a must), that supports opening and saving in UTF-8.
Tried a few like BKReplaceEm but the application ends up saving all the files as ASCII which causes some problems with web-rendering.
Please advise.
...
Let's say I have some code like the following, and that processData gets executed hundreds or even thousands of times per minute:
class DataProcessor {
private:
DataValidator* validator;
bool atLeastOneDataPoint;
bool dataIsValid(Data* dataToValidate) {
return validator->validate(dataToValidate);
}
public:
/...
I read the following sentence in the Fluent NHibernate wiki:
...; however, for most greenfield applications (and quite a few brownfield ones too) auto mapping will be more than capable.
What are greenfield and brownfield applications?
...
We've got a product that's made up of C++ and Java parts. The C++ stuff is build using make and the java projects are made up of some ant projects and some maven2 projects.
I'm looking for a tool that will help me get useful metrics out of the build system over time. examples include
* Total build time
* C++ project build time
* Java...
Now I am trying to come up with a data structure for implementing a telephone adreess book.
Say there are two infos : name, telephone numbers. The same name can have more than one number.
Now i would like to come up with a data structure that will help me in fetching the number given a name and fetching the name, given a number. I have t...
It's a simple problem. Sometimes Windows will just halt everything and throws a BSOD. Game over, please reboot to play another game. Or whatever. Annoying but not extremely serious...
What I want is simple. I want to catch the BSOD when it occurs. Why? Just for some additional crash logging. It's okay that the system goes blue but when ...
How would you go about hiding sensitive information from going into log files? Yes, you can consciously choose not to log sensitive bits of information in the first place, but there can be general cases where you blindly log error messages upon failures or trace messages while investigating a problem etc. and end up with sensitive inform...
When your in a situation where you need to return two things in a single method, what is the best approach?
I understand the philosophy that a method should do one thing only, but say you have a method that runs a database select and you need to pull two columns. I'm assuming you only want to traverse through the database result set onc...
I'm doing some work processing some statistics for home approvals in a given month. I'd like to be able to show trends - that is, which areas have seen a large relative increase or decrease since the last month(s).
My first naive approach was to just calculate the percentage change between two months, but that has problems when the data...
Is there some cheap and reliable way to detect if an image file has EXIF data? Something like "read the first 100 bytes and search for EXIF substring" is highly preferable. I don't need to read and parse it - only to know if it is there.
The key is that it must be very fast. C++ is preferable.
...