daily pastebin goal
72%
SHARE
TWEET

Untitled

a guest Jan 19th, 2019 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fun remove(original, final, n, i) = if null original then final
  2.                                 else if i = n then remove(tl(original), final, n, i+1)
  3.                                 else remove(tl(original), final @[hd(original)],n,i+1);
  4.  
  5. fun rem k list = remove(list, [], k, 1);
  6.  
  7. fun det(list) =  let val a = hd(list);
  8.                  val b = hd(tl(list));
  9.                  val c = hd(a);
  10.                  val d = hd(tl(a));
  11.                  val e = hd(b);
  12.                  val f = hd(tl(b)); in
  13.  
  14.                  c*f - d*e end;
  15.  
  16.  
  17. fun operate(a,b,i)= if a=b then a-b else a+b;
  18.  
  19. fun compute(matrix,list,ans,i) = if null list then ans
  20.                             else compute(matrix,tl(list), operate(ans, hd(list)*det(map (rem i) (tl(matrix))), i), i+1);
  21. fun value(matrix) = compute(matrix,  hd(matrix), 0, 1);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top