REBOL [ Title: "Transpose" Date: 3-Jul-2002 Name: Transpose Version: 1.0.0 File: %Transpose.r Author: "Andrew Martin" Purpose: "Transposes a Matrix's rows and columns." Email: Al.Bri@xtra.co.nz Web: http://valley.150m.com Category: [util math 3] Acknowledgements: [ "Joel Neely" "Gerald Goertzel" "Larry" ] Example: [ transpose [[1 2 3 4 5] ["a" "b" "c" "d" "e"]] transpose [[1 2 3] [14 15 16] [27 28 29]] ] ] Transpose: function [ "Transposes a Matrix's rows and columns." [catch] Matrix [block!] "The Matrix." ][ Rows Columns Transposed ][ throw-on-error [ Rows: length? Matrix Columns: length? Matrix/1 Transposed: array reduce [Columns Rows] repeat Row Rows [ repeat Column Columns [ poke pick Transposed Column Row pick pick Matrix Row Column ] ] Transposed ] ]