| The Wu-Tang Clan's IT Team Lead ( @ 2005-06-10 10:57:00 |
Boring stuff
I'm playing around with writing a library to do matrix arithmetic in my dinky Scheme implementation. I decided to compute determinants by expanding cofactors, so I wrote this function to get the minor of row n and column m of a matrix (that is, the matrix left when row n and column m are deleted). Since I am treating a matrix as simply a list of row lists:
(define (minor matrix n m)
(transpose (except-nth (transpose (except-nth matrix n)) m)))
If I'd written this in C, it would have been a nightmare of for statements. I like Scheme.
I'm playing around with writing a library to do matrix arithmetic in my dinky Scheme implementation. I decided to compute determinants by expanding cofactors, so I wrote this function to get the minor of row n and column m of a matrix (that is, the matrix left when row n and column m are deleted). Since I am treating a matrix as simply a list of row lists:
(define (minor matrix n m)
(transpose (except-nth (transpose (except-nth matrix n)) m)))
If I'd written this in C, it would have been a nightmare of for statements. I like Scheme.