Tag Info

Hot answers tagged

14

Wikipedia (and my math teacher) tells me: Stacked exponents are applied from the top down. This is reflected the way Python evaluates it. Microsoft is wrong (once more) And Ruby evaluates it as Python, so it's correct without doubt, since Matz can't be wrong.


8

The definition from wikipedia seems correct and general enough: collection of unique keys and a collection of values, where each key is associated with one value (or set of values) Not a word about order. That should be perfectly fine, as there are many good ways to implement data structures that are perfect associative arrays, only without the ...


8

I'm not certain if the enumerator is reset if an enumeration is not completed, so if that's a worry, then who knows at what point the enumeration would start? Enumerating an array would always start at the beginning. These two sentences make me think that you have deep misunderstandings about how the enumerable pattern works. Can you explain why you ...


3

Logically, the problem as defined requires a check that there is at least one argument for the help case, as well as a check that there are at least two arguments for the normal use case. Think about what you have to say to describe the program's behavior: [The program] requires at least two command-line arguments... Then I also want to allow ...


3

I believe your requirements are theoretically impossible to implement. Is there no way to check whether the web service has received the records? Some other service operation? If so you could check before you submit. Also check with the service owner to see if they can make their service idempotent. Or set up a manual process to handle the failures.


2

It's always possible to come up with an even worse case that ruins whatever solution you come up with. Assume a hostile web service, or a hostile database, and you're screwed. But in the scenario you describe, you mainly need a more reliable action log than an external database. Let's assume that the local file system is reliable if you don't increase file ...


2

Split (conceptualy) your View into ViewView and ViewModel. In view model you will have things like order of columns, number of rows on page, current page, whether you are in edit mode. Simply things that you need to store, but does not make sense to store them in model (different view will not use them). In what form view model is stored depends on view. It ...


2

Command line utilities, in my experience, tend to be universally ugly when it comes to being flexible when parsing args, especially when you have a command that can take an arbitrary number of arguments. There will almost always be some level of duplication or cross-checking, because at its heart the tool is likely short, which means it's probably a single ...


2

I think that you want to combine 2 different concepts into 1. The data structure and its contents order are 2 separate things. Ordering is a tricky subject. For example, what does ordering a list of persons mean? Even when order/sort key is defined, it has to have a direction and you have to decide what to do with nulls (if any), date issues, etc. If data ...


1

No way. C is a brilliant language (and incidentally is far more lightweight than C++, if you ever need this), but it isn't object-oriented. Because of this, at the very start of a project, when you sit down and work out how you're going to work it, you'd likely come up with two different approaches depending on C or C++. I would do the same as you - go ...


1

Wouldn't a simple class be better here than a list? You can create a class which has the three elements in it and then a constructor/factory method to create it in the required order. For example: public class Wrapper { public Type1 MainObject { get; set; } public List<Type2> SubElements { get; set; } public List<Type3> ...


1

I would solve it like this: // returns a list of elements, ordered by type 1, type 2 and type 3 public List<IElement> CreateElementsOrdered(...) { ... } Since the name and the comment of your function define the contract, every consumer of your method can rely on the fact that the list is ordered in this way. On the other hand, anyone modifying ...


1

IEnumerable declares that the collection you have can be enumerated; it doesn't imply anything about the content. This isn't a bad thing -- containers can have additional capabilities and restrictions on top of individual interfaces. (I don't see how an array is any better here -- it's indexable, as is an IList and other containers, but there is nothing ...


1

There seem to be two (2) questions, or perhaps two interpretations for your question that one could take: Do associative arrays, as they are defined in a theoretical sense imply any kind of ordering Is there an underlying ordering of the elements in an associative array implementation in language XYZ? Since your question sports the language-agnostic tag, ...



Only top voted, non community-wiki answers of a minimum length are eligible