Make computation parallel
This commit is contained in:
@@ -51,6 +51,7 @@
|
|||||||
# maths
|
# maths
|
||||||
primes
|
primes
|
||||||
arithmoi
|
arithmoi
|
||||||
|
parallel
|
||||||
|
|
||||||
# graphing libraries!
|
# graphing libraries!
|
||||||
# Chart
|
# Chart
|
||||||
|
|||||||
@@ -3,13 +3,21 @@ The Simplest Math Problem No One Can Solve - Collatz Conjecture
|
|||||||
https://youtu.be/094y1Z2wpJg
|
https://youtu.be/094y1Z2wpJg
|
||||||
-}
|
-}
|
||||||
|
|
||||||
import Data.Set (fromList)
|
import Control.Parallel.Strategies
|
||||||
import Debug.Trace (trace)
|
import Data.Containers.ListUtils
|
||||||
|
import Debug.Trace (trace)
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
let results = map f [10^1_000..10^1_000+100] :: [Integer]
|
let start = 2^1_000_000
|
||||||
print (fromList results)
|
let end = 100
|
||||||
|
-- let message = "Starting at " <> show start <> ", and computing " <> show end <> " values."
|
||||||
|
let message = "Starting at 2^1_000_000, and computing " <> show end <> " values."
|
||||||
|
let results = parMap rpar f [start..start+end] :: [Integer]
|
||||||
|
putStrLn "======================================"
|
||||||
|
putStrLn message
|
||||||
|
print $ nubOrd results
|
||||||
|
putStrLn "======================================"
|
||||||
|
|
||||||
lst :: [Integer]
|
lst :: [Integer]
|
||||||
lst = take 300 [2^100_000..]
|
lst = take 300 [2^100_000..]
|
||||||
|
|||||||
Reference in New Issue
Block a user