Created
December 3, 2009 23:26
-
-
Save lenstr/248665 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- successively select elements from xs and remove one in each result list -} | |
import List | |
removeEach :: [a] -> [[a]] | |
removeEach xs = | |
zipWith (++) (List.inits xs) (tail (List.tails xs)) | |
alternate :: (Num a) => [a] -> [a] | |
alternate = zipWith id (cycle [id, negate]) | |
det :: (Num a) => [[a]] -> a | |
det [] = 1 | |
det m = sum (alternate | |
(zipWith (*) (map head m) | |
(map det (removeEach (map tail m))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment