899 reputation
310
bio website
location
age
visits member for 2 years, 1 month
seen Jun 24 at 18:44

Jun
5
comment Problem in working with async and await?
clearly files is being modified somewhere. It's not modified here, but it clearly is being modified somewhere.
Jun
5
comment Problem in working with async and await?
You most certainly can. You generally shouldn't, and it does result in a warning if a method is async and has no await.
May
30
awarded  Yearling
Feb
3
comment What are the advantages of next-iterator over this-iterator?
@greenoldman So when calling IsValid what you're actually doing is going and getting the next value. This means it's doing exactly the same thing as the existing iterator (it doesn't have the current valid from the start, without needing to call a method to go get it) it just has a mis-leading name.
Feb
3
comment What are the advantages of next-iterator over this-iterator?
@NiksTyagi It is a conceptual question that applies equally to both, as the proposed design is different from either language's implementation.
Feb
3
answered What are the advantages of next-iterator over this-iterator?
Jan
31
comment Super Fast File Storage Engine
@GrandmasterB It'd be 10mb per file. There would be 100 million files, as each file represents just one group of 10,000. If the groups average 10,000 records, and there are 1 trillion records, the division says there are 100 million groups. No idea if that many files is going to be a problem for the file system. My guess is yes, but I'm not sure if there are ways of handling that.
Jan
30
comment What rationale is used when programming language designers decide what sign the result of modulo operation takes?
"Going through Euclidean division I found that remainnder of this operation is always positive (or 0). What limitation of the underlying computer hardware forces programming language designers to differ from mathematics?" None, generally. It's generally going to be an intentional decision one way or the other.
Jan
30
comment How do I traverse a tree without using recursion?
@RobertHarvey I'm going to play devil's advocate on this one and say that choosing the proper data structure for an algorithm isn't entirely about resource optimization. Some data structures (in fact, most frequently the preferable from a performance standpoint) have operations that simply lend themselves to more easily solving a given problem. Having said that, I do generally think about the performance implications whenever deciding on a data structure.
Jan
30
comment How do I traverse a tree without using recursion?
@MathewFoscarini How so? You can just foreach over the sequence and perform some operation on each item in the sequence, as your code appears to be doing.
Jan
30
comment How do I traverse a tree without using recursion?
@MathewFoscarini Yes, that's its purpose. Of course, it doesn't need to necessarily be materialized into an actual collection. It's just a sequence. You can iterate over it to stream the data, without needing to pull the entire data set into memory.
Jan
30
comment How do I traverse a tree without using recursion?
How do you define recursion then? I would define it as a function that invokes itself within its own definition. You can most certainly traverse a tree without ever doing that, as I have demonstrated in my answer.
Jan
30
revised How do I traverse a tree without using recursion?
added 122 characters in body
Jan
30
comment How do I traverse a tree without using recursion?
@KarlBielefeldt That assumes the tree is perfectly balanced though. Sometimes you need to be modeling trees that aren't balanced, and in that case it's very easy to blow the stack.
Jan
30
comment How do I traverse a tree without using recursion?
This is simply false. It is most certainly possible to traverse a tree without using recursion. It's not even hard. You can also do so more efficiently, quite trivially, as you can only include as much information in the explicit stack as you're sure you need for your specific traversal, whereas using recursion you end up storing more information than you actually need in many cases.
Jan
30
answered How do I traverse a tree without using recursion?
Nov
26
answered How to calculate the worst-case runtime of this search-algorithm
Nov
15
comment How to handle divide by zero in a language that doesn't support exceptions?
But only in certain cases; it can't do so, with 100% accuracy, in all cases. You'll either have false positives or false negatives. This is provably true. For example, I could create a snippet of code that may or may not even complete. If the compiler can't even know if it finished, how could it know if the resulting int is non-zero? It can catch simple obvious cases, but not all cases.
Nov
15
comment How to handle divide by zero in a language that doesn't support exceptions?
If you don't have a different type, one for zero and one for non-zero values, then you wouldn't be able to solve the problem in the general case. You'd either have false positives, and force the user to check against zero way more often than they actually should, or you'll create situations where they can still divide by zero.
Nov
15
comment How to handle divide by zero in a language that doesn't support exceptions?
To do this you need a new numeric type, a natural number, as opposed to an integer. That could be...difficult...to deal with.