Python 2, prints a two-dimensional nested list clockwise, from the top left corner to the center:
>>> def clockwise(r):
... return list(r[0]) + clockwise(list(reversed(zip(*r[1:])))) if r else []
...
>>> a = [
... [ 1, 2, 3],
... [ 5, 6, 7],
... [ 9, 10, 11]]
>>> clockwise(a)
[1, 2, 3, 7, 11, 10, 9, 5, 6]
>>> a = [
... [ 1, 2, 3, 4],
... [ 5, 6, 7, 8],
... [ 9, 10, 11, 12],
... [13, 14, 15, 16]]
>>> clockwise(a)
[1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10]
? clockwise r. , . , , , . ( ). . , , , . , ( ), .
, , Haskell:
import Data.List
clockwise :: [[a]] -> [a]
clockwise (x:xs) = x ++ (clockwise $ reverse $ transpose $ xs)
clockwise _ = []