Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Elegant solutions

Name: Anonymous 2007-06-28 15:16 ID:lcs47ZU6

Im bored, show me some good code (any language whatsoever)
Post a problem, then a great solution.

1) Transpose a matrix
(apply #'mapcar #'list '(( 1  2  3  4)
                         ( 5  6  7  8)
                         ( 9 10 11 12)
                         (13 14 15 16)))
(( 1  5  9 13)
 ( 2  6 10 14)
 ( 3  7 11 15)
 ( 4  8 12 16))

Name: Anonymous 2007-06-28 16:31 ID:Heaven

matmul a b = map (\r -> map (sum . (zipWith (*) r)) (transpose b)) a

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List