Dear Tzango, > Is there any particular reason why when one tries to iterate over > IntegerVectors(k,n) one gets the vectors represented as lists and not > tuples? The only difference between the two that I can think of is > that lists are mutable and tuples aren't. I cannot see why being > mutable is an advantage. On the other hand, if the vectors weren't > mutable one could use them as keys to a dictionary e.g.: > > sage: p = MixedIntegerLinearProgram() > sage: v = p.new_variable() > sage: p.set_objective(sum(v[i] for i in IntegerVectors(2,3))) > > Now I need to write > sage: p.set_objective(sum(v[tuple(i)] for i in IntegerVectors(2,3)))
Mutable is an advantage in the sense that if you want to modify the vector you have to make a copy of it. (This sentence looks like a tautology !). There is some plan to make the result type (and parent) configurable. Note that someone could find it more natural to get the result not as a double but rather as a true vector as we can get using sage: v = vector([1,2,3]); v (1, 2, 3) sage: type(v) <type 'sage.modules.vector_integer_dense.Vector_integer_dense'> sage: v.parent() Ambient free module of rank 3 over the principal ideal domain Integer Ring I'm not sure why we (maybe = Mike Hansen) finally chose list. I don't think one is better. We should allow both. Cheers, Florent -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org