News for hackers. Stuff that matters.
Re:Python iteration by kisielk on Wednesday April 25, 2012 @04:19PM (#3890847)
What data structure are you using to represent your matrix? A list of lists? If so, it's not terribly difficult:

    >>> a = [[1,2,3], [4,5,6], [7,8,9]]
    >>> b = zip(*map(reversed, reversed(a))
    >>> b
    [(9, 6, 3), (8, 5, 2), (7, 4, 1)]
    >>> reduce(operator.add, b) # could also use a lambda with + instead of operator.add...
    (9, 6, 3, 8, 5, 2, 7, 4, 1)

There are no comments on this comment yet.