Guest User

Untitled

a guest
May 16th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. {- successively select elements from xs and remove one in each result list -}
  2.  
  3. import List
  4.  
  5. removeEach :: [a] -> [[a]]
  6. removeEach xs =
  7. zipWith (++) (List.inits xs) (tail (List.tails xs))
  8.  
  9. alternate :: (Num a) => [a] -> [a]
  10. alternate = zipWith id (cycle [id, negate])
  11.  
  12. det :: (Num a) => [[a]] -> a
  13. det [] = 1
  14. det m = sum (alternate
  15. (zipWith (*) (map head m)
  16. (map det (removeEach (map tail m)))))
Add Comment
Please, Sign In to add comment