Compute determinant

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Compute determinant


I want to make a program that computes the determinant of a matrix.For example
mdet [[1,2],[3,4]]=-2. Ihave started by writing the following but it doesn't compile

head1 []=[]
head1 (x:xs)=x

deselect 1 (x:xs)=xs
deselect (n+1) (x:xs)=x: (deselect n xs)

deselectall k []=[]
deselectall k (x:xs)=((deselect k x): (deselectall k xs))

function(x:xs,n)=(head1 x)*function(deselectall n xs,1) - mdet((drop 1 x):xs,n+1)


Could you please give me any hints to correct it?

Thank you in advance