Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Give the antidiagonal of a matrix
| ResourceFunction["Antidiagonal"][m] gives the list of elements on the leading antidiagonal of the matrix m. | |
| ResourceFunction["Antidiagonal"][m,k] gives the elements on the kth antidiagonal of m. | 

Give the antidiagonal elements of a matrix:
| In[1]:= | ![ResourceFunction["Antidiagonal"][{{a, b, c}, {d, e, f}, {g, h, i}}]](https://www.wolframcloud.com/obj/resourcesystem/images/8af/8afd7db5-1263-4ebe-8f63-3734cbdc78e9/4b386de6797de4d5.png) | 
| Out[1]= |  | 
Give antidiagonals one element above and below the leading diagonal:
| In[2]:= | ![ResourceFunction["Antidiagonal"][{{a, b, c}, {d, e, f}, {g, h, i}}, 1]](https://www.wolframcloud.com/obj/resourcesystem/images/8af/8afd7db5-1263-4ebe-8f63-3734cbdc78e9/55a9974969af55ce.png) | 
| Out[2]= |  | 
| In[3]:= | ![ResourceFunction[
 "Antidiagonal"][{{a, b, c}, {d, e, f}, {g, h, i}}, -1]](https://www.wolframcloud.com/obj/resourcesystem/images/8af/8afd7db5-1263-4ebe-8f63-3734cbdc78e9/22987b60e3898e77.png) | 
| Out[3]= |  | 
Give an antidiagonal of a nonsquare matrix:
| In[4]:= | ![ResourceFunction[
 "Antidiagonal"][{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}]](https://www.wolframcloud.com/obj/resourcesystem/images/8af/8afd7db5-1263-4ebe-8f63-3734cbdc78e9/54f1c42ce332b7ce.png) | 
| Out[4]= |  | 
If k is too high or too low, an empty list is returned:
| In[7]:= | ![ResourceFunction["Antidiagonal"][{{a, b, c}, {d, e, f}, {g, h, i}}, 3]](https://www.wolframcloud.com/obj/resourcesystem/images/8af/8afd7db5-1263-4ebe-8f63-3734cbdc78e9/1530041c9c811fac.png) | 
| Out[7]= |  | 
Rotate a matrix by 45 degrees:
| In[8]:= | ![Row[Column[
    ResourceFunction[
     "Antidiagonal"][{{a, b, c}, {d, e, f}, {g, h, i}}, #]] & /@ Range[2, -2, -1]]](https://www.wolframcloud.com/obj/resourcesystem/images/8af/8afd7db5-1263-4ebe-8f63-3734cbdc78e9/16d6fd201b5aa154.png) | 
| Out[8]= |  | 
This work is licensed under a Creative Commons Attribution 4.0 International License