2014-09-08 8:07 UTC+02:00, Nathann Cohen <[email protected]>: >> When Sage does something different than what I expect, I look at the doc >> instead of wondering why it's different > > When a list becomes a tuple and all of a sudden a 10 lines functions (that > calls other functions) returns wrong answers I swear that you don't. Come > on Travis open your eyes, this thing is dead misleading.
For me, here Permutation((1,2,3)) vs Permutation([1,2,3]) is a source of confusions for programmers! Not for users. There are many places in Python where iterators return tupes and there are many places in Sage where iterators return lists... >> It's not a bug because it's not doing something wrong. It's just doing >> something different than you expect. Moreover I would not necessarily > expect >> those two to behave in the same way because I'm giving different input; >> especially for p(1) and p[1]. > > Travis, you can't even expect an user to be able to get the doc for () and > []. And it's not even the problem. This [] notation is about considering a > 1-based permutation as a 0-based arrays that returns 1-based indices. > > Can you really not see that it is a bad idea ? This is not so bad. You can consider a permutation as an ordered word, ie a bijection 0..n-1 to your domain. And then p[i] makes sense: it gives you the letter at position i (0 based). And by the way, it is the way it is printed on screen sage: Permutation([3,2,1]) [3, 2, 1] so you expect it to work more or less like a list. And this is what it does with respect to []. The notation perm(i) clearly refers to the fact that you consider the permutation as a map A -> A. Now mixing bijection 0..n-1 -> A with bijection A -> A is not necessarily a good idea... unless A is totally ordered and there is a prefered 0..n-1 -> A bijection which would correspond to the identity map. Vincent -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
