Ask Your Question
1

How to list weak compositions?

asked 2025-05-31 04:23:19 +0200

Comb4 gravatar image

I would like to know if there's a way to list weak compositions in SageMath Similar to: list(Compositions(2, length=2)) The result is: [[1, 1]] I would like to have: [[1, 1],[2, 0],[0, 2]]

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2025-06-02 12:42:18 +0200

Max Alekseyev gravatar image

IntegerVectors do that. E.g. IntegerVectors(2,2).list() give [[2, 0], [1, 1], [0, 2]] as requested.

edit flag offensive delete link more

Comments

It would be nice to have a "See also: IntegerVectors" in the documentation for Compositions.

slelievre gravatar imageslelievre ( 2025-06-17 10:32:25 +0200 )edit

I see such "See also" there. Don't you?

Max Alekseyev gravatar imageMax Alekseyev ( 2025-06-17 11:35:25 +0200 )edit

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: 2025-05-31 04:23:19 +0200

Seen: 244 times

Last updated: Jun 02