Cale Gibbard wrote:
I'd use a Map in GHC 6.4:
count xs = toList $ fromListWith (+) (zip xs (repeat 1))
or a FiniteMap in earlier versions:
count xs = fmToList $ addListToFM_C (+) emptyFM (zip xs (repeat 1))
both of these seem to be quite fast.

- Cale

Thanks, this is significaly faster than variant with accumArray i've used before.


By the way, how to use Unboxed arrays and unsafeAccumArray Greg Buchholz mentioned? I can't find them in GHC 6.2 documentation.

And last question:

When I try to compile my program with -caf-all I get these messages:
% ghc -prof -caf-all mastermind.hs -o mastermind


/tmp/ghc3338.hc:25: error: redefinition of `Mainmain_CAF_cc_ccs'
/tmp/ghc3338.hc:24: error: `Mainmain_CAF_cc_ccs' previously defined here

If I use -auto-all it works fine.

I use Slackware Linux 10.1 with gcc 3.3.4 and ghc-6.2.2


_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to