Compute determinant

View: New views
1 Messages — Rating Filter:   Alert me  

Compute determinant

by Tindin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

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([a],m)=a
function(x:xs,n)=(head1 x)*function(deselectall n xs,1) - mdet((drop 1 x):xs,n+1)

mdet(ys)=function(ys,1)

Could you please give me any hints to correct it?

Thank you in advance
LightInTheBox - Buy quality products at wholesale price