3 add 1x1 example
source | link

Julia 0.6, 28 24 bytes

~A=sum(rotr90.([A],0:3))

Try it online!Try it online!

~A=sum(rotr90.([A],0:3)) #
~                        # redefine unary operator ~
 A                       # function argument
               [A]       # put input matrix A into a list with one element
                   0:3   # integer range from 0 to 3
       rotr90.(   ,   )  # apply function rotr90 elementwise, expand singleton dimensions
       rotr90.([A],0:3)  # yields list of rotated matrices:
                         # [rotr90(A,0), rotr90(A,1), rotr90(A,2), rotr90(A,3)]
  sum(                )  # sum

Julia 0.6, 28 24 bytes

~A=sum(rotr90.([A],0:3))

Try it online!

~A=sum(rotr90.([A],0:3)) #
~                        # redefine unary operator ~
 A                       # function argument
               [A]       # put input matrix A into a list with one element
                   0:3   # integer range from 0 to 3
       rotr90.(   ,   )  # apply function rotr90 elementwise, expand singleton dimensions
       rotr90.([A],0:3)  # yields list of rotated matrices:
                         # [rotr90(A,0), rotr90(A,1), rotr90(A,2), rotr90(A,3)]
  sum(                )  # sum

Julia 0.6, 28 24 bytes

~A=sum(rotr90.([A],0:3))

Try it online!

~A=sum(rotr90.([A],0:3)) #
~                        # redefine unary operator ~
 A                       # function argument
               [A]       # put input matrix A into a list with one element
                   0:3   # integer range from 0 to 3
       rotr90.(   ,   )  # apply function rotr90 elementwise, expand singleton dimensions
       rotr90.([A],0:3)  # yields list of rotated matrices:
                         # [rotr90(A,0), rotr90(A,1), rotr90(A,2), rotr90(A,3)]
  sum(                )  # sum
2 use element-wise function application to save 4bytes
source | link

Julia 0.6, 2828 24 bytes

~A=sum(rotr90.(A[A],x)for x=00:3))

Try it online!

Redefines the unary operator ~.
An array comprehension builds a list of 4 rotated matrices, which is then summed.Try it online!

~A=sum(rotr90.([A],0:3)) #
~                        # redefine unary operator ~
 A                       # function argument
               [A]       # put input matrix A into a list with one element
                   0:3   # integer range from 0 to 3
       rotr90.(   ,   )  # apply function rotr90 elementwise, expand singleton dimensions
       rotr90.([A],0:3)  # yields list of rotated matrices:
                         # [rotr90(A,0), rotr90(A,1), rotr90(A,2), rotr90(A,3)]
  sum(                )  # sum

Julia 0.6, 28 bytes

~A=sum(rotr90(A,x)for x=0:3)

Try it online!

Redefines the unary operator ~.
An array comprehension builds a list of 4 rotated matrices, which is then summed.

Julia 0.6, 28 24 bytes

~A=sum(rotr90.([A],0:3))

Try it online!

~A=sum(rotr90.([A],0:3)) #
~                        # redefine unary operator ~
 A                       # function argument
               [A]       # put input matrix A into a list with one element
                   0:3   # integer range from 0 to 3
       rotr90.(   ,   )  # apply function rotr90 elementwise, expand singleton dimensions
       rotr90.([A],0:3)  # yields list of rotated matrices:
                         # [rotr90(A,0), rotr90(A,1), rotr90(A,2), rotr90(A,3)]
  sum(                )  # sum
1
source | link

Julia 0.6, 28 bytes

~A=sum(rotr90(A,x)for x=0:3)

Try it online!

Redefines the unary operator ~.
An array comprehension builds a list of 4 rotated matrices, which is then summed.