real 0m1.409s
user 0m1.406s
sys 0m0.002s
$ time ./smp3 +RTS -N2
[90,7,7,0,5,63,7,11,31,3]
real 0m0.834s
user 0m1.564s
sys 0m0.046s
$ time ./smp3 +RTS -N4
[90,7,7,0,5,63,7,11,31,3]
real 0m0.545s
user 0m1.576s
sys 0m0.036s
module Main where
import Data.Maybe
import Control.Parallel.Strategies
import Control.Parallel
factors n = let candidates = [2..floor (sqrt (fromInteger n))]
in catMaybes $ map (\x ->
if n `mod` x == 0
then Just (x, n `div` x)
else Nothing) candidates
bigNums = [2000000000000..]
answer = (parMap rwhnf) (length . factors) (take 10 bigNums)
main = print answer
Name:
Anonymous2008-05-16 7:24
I am a programmer. I have dealt in many languages, but I have ended up with Haskell. Haskell is the best language for implementing general programs.
Haskell is fast. It's no Common Lisp/Scheme, but it's head and shoulders above comparable high-level languages.
Haskell is memory-managed.
Haskell supports just the right level of features. It doesn't have Schemes's feature fetish.
Haskell has an expansive, (mostly) cross-platform API. It's not perfect, but it sure beats writing everything yourself.
Haskell and its API are constantly being improved.
In any program of significant size, the problem isn't writing your Bloom filters or splay trees with elegant syntax. It's a problem of communication with other programmers (including library-writers). Haskell's strict typing, rigid structure, documentation system, and excellent developer tools (aka Eclipse) all help you out.
It's not perfect. Sure, first-class functions would be nice, but you never use them except on your homework assignment where you pass the comparator to a sort function. If you're building a little toy program, it's a pain to put everything in an object, but you'll be thankful you did once that program gets big enough. The syntax sucks, but it's familiar. Sure, GHC is slow, but suck it up big balls.
Haskell isn't perfect, but it's the best in practice.
Name:
Anonymous2008-05-16 7:38
and excellent developer tools (aka Eclipse) all help you out.
I think you mean Microsoft Visual Haskell Studio .NET.
Name:
Anonymous2008-05-16 7:57
>>2 Sure, first-class functions would be nice,
This copypasta is undercooked.
Name:
Anonymous2008-05-16 8:22
first-class functions would be nice,
that's actually the only thing i wish was in C99 that isn't.
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy