Skip to content

Instantly share code, notes, and snippets.

@kouddy
Created April 27, 2015 02:25
Show Gist options
  • Save kouddy/307619abdc2d8b82e237 to your computer and use it in GitHub Desktop.
Save kouddy/307619abdc2d8b82e237 to your computer and use it in GitHub Desktop.
(define (dot-product v w)
(accumulate + 0 (map * v w)))
(define (matrix-*-vector m v)
(map (lambda (row) (dot-product row v))
m))
(define (transpose mat)
(accumulate-n cons null mat))
(define (matrix-*-matrix m n)
(let ((cols (transpose n)))
(map (lambda (row)
(map (lambda (col)
(dot-product row col))
cols))
m)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment