Created
November 15, 2012 15:13
-
-
Save anonymous/4079107 to your computer and use it in GitHub Desktop.
Parallel Vector Spaces
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
module Main where | |
import Control.Parallel.Strategies | |
import Control.Monad | |
import Data.List | |
data S = One | Z | |
deriving (Show, Eq) | |
vectorSpace n = replicateM n [One,Z] | |
zeroCount n = foldl f (0,0) (vectorSpace n `using` parListChunk 1000 strategy) | |
where | |
f a1 x1 = ((zeros x1) + (fst a1), (ones x1) + (snd a1)) | |
strategy = r0 | |
zeros l = length $ filter (== Z) l | |
ones l = length $ filter (== One) l | |
main = do | |
putStrLn . show $ zeroCount (2^5) | |
return () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment