First time here? Check out the FAQ!

Ask Your Question
1

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

asked 7 years ago

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 7 years ago

slelievre gravatar image
Preview: (hide)
link

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: 7 years ago

Seen: 1,097 times

Last updated: Mar 07 '18