Ask Your Question
1

What is a possibility to tell Sage to turn a list into a multiset?

asked 2018-03-07 11:32:08 +0200

Peter Heinig gravatar image

A well-known computer algebra package features a useful command called 'Tally', which e.g. takes a list like 2,1,2,2,3,1 and returns the list of pairs (1,2),(2,3),(3,1), where the second component of each pair equals the multiplicity of the first component of the pair in the input list. Currently, I am learning more Sage, and I need some functionality like the above.

My question. Is there a 'native' way to do the same in Sage? Of course, I could program something like this, but what is, in your opinion, the currently 'best' way to turn an arbitrary list into a multiset, with the multiplicities conveniently recorded?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-03-07 14:51:22 +0200

slelievre gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2018-03-07 11:32:08 +0200

Seen: 919 times

Last updated: Mar 07 '18