Ticket #750 (closed enhancement: fixed)
[with patch] permutation group element (dict method, acting on lists)
| Reported by: | jason | Owned by: | boothby |
|---|---|---|---|
| Priority: | minor | Milestone: | sage-2.8.11 |
| Component: | combinatorics | Keywords: | |
| Cc: | sage-combinat | Work issues: | |
| Report Upstream: | Reviewers: | ||
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description
It would be nice to get permutation elements as dictionaries as well as lists. If g is a permutation group element, then something like
sage: g.dict()
{1:2, 2:1}
It would also be nice if we could have permutation elements act on lists to switch the order according to the permutation.
sage: g.action(range(3)) [0,2,1]
Are these things possible already?
Attachments
Change History
comment:2 Changed 6 years ago by boothby
Added a patch to implement something similar to the second. With this patch, one may do the following:
sage: G = SymmetricGroup(4)
sage: g = G((1,2,3,4))
sage: sage: g('abcd')
'bcda'
sage: sage: g([0,1,2,3])
[1, 2, 3, 0]
sage: sage: g(('foo','bar','baz','what'))
('bar', 'baz', 'what', 'foo')
However, I can see absolutely no reason for one to want a dict rather than a list. Do you have an example of where this might be useful?
comment:3 Changed 6 years ago by boothby
- Owner changed from was to boothby
- Status changed from new to assigned
- Milestone changed from sage-feature to sage-2.8.11
Robert Miller convinced me that there are good reasons to want a dict, so I implemented this, too.
Changed 6 years ago by boothby
-
attachment
750.1.2.hg
added
fixes bugs from previous edition / ready for 2.8.11
comment:4 Changed 6 years ago by mabshoff
- Summary changed from permutation group element (dict method, acting on lists) to [with patch] permutation group element (dict method, acting on lists)
