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