I quite don't understand what is the difference between major and minor diagonal so cannot come up with a good way to get a list of diagonals.

A major diagonal starts at the top left and finished at the bottom right. A minor diagonal starts sat the top right and finishes at the bottom left.

The minor diagonal is top right to bottom left, while the major diagonal is top left to bottom right. So if you have a 3 x 3 table:

XOO OXO OOX

The Xs are along the major diagonal above.

OOX OXO XOO

The Xs are now along the minor diagonal.

Got it. Thanks a lot