Skip to content

Instantly share code, notes, and snippets.

Created November 15, 2012 15:13
Show Gist options
  • Save anonymous/4079107 to your computer and use it in GitHub Desktop.
Save anonymous/4079107 to your computer and use it in GitHub Desktop.
Parallel Vector Spaces
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