# Tag Info

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.

11

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 think ...

10

The reason why in mathematics stacked exponents are applies from the top down is that the other way you just get multiplication of exponents: (((2^3)^4)^5) = 2^(3 * 4 * 5)

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 "...

5

I see where most readings online derive that the Big-Oh notation of a Binary Search is O(log(n)), but doesn't this assume a balanced tree? What if the tree is completely unbalanced (i.e. similar to a linked list). In this case the height of the tree is not log(n) it is n. Binary Search doesn't assume a tree at all. Binary Search assumes a data structure ...

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

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 ...

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

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 ...

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

Yes, the assumption is that it is a balanced binary tree, or at least one that is randomly loaded. The linked list scenario is only one configuration of many, and your odds of getting it by chance are vanishingly small, unless you sort your nodes first, before inserting them into the tree. Searches in a balanced binary tree are O(log(n)) in the worst ...

1

Could there be a way to dodge this issue by turning "order" from a possibly transient object into an action performed by an object whose state you have more direct control over? Let's assume four object types (classes or prototypes, depending on what you're working with): Customer, Product, Cart, and Receipt. For clarity's sake, instance objects are ...

1

I'll answer your question with two questions: Is it a bad thing to have to delete an order object? Is an order object invalid if it's supposed to be paid for (i.e., not merely waiting to be paid and picked up) but the payment hasn't come through? If the answer to both questions is "yes," then you don't have a choice. A failed payment will leave you in a ...

1

One obvious solution is to use arbitrary precision arithmetic. As an implementation with big.js: var Big = require('./big.js'); function average(x, y) { // exact result; .div(2) requires specifying .DP return Big(x).plus(y).times(0.5); } var x = new Big(1); var y = new Big(2); for (i = 0; i <= 10; i++) { x = average(x, y); console.log(x....

1

Personally I would just put it in a loop Here's psudo code for it. while mainList has items { find first 0 item. add to queue, remove from mailList find first 1 item add to queue, remove from mailList find first 3 item. add to queue, remove from mailList find first 4 item. add to queue, remove from mailList } return queue

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