
Am Freitag 19 März 2010 02:56:36 schrieb zaxis:
%cat Test.hs module Test(mcombs) where import Data.List
mcombs = foldr (flip (>>=) . f) [[]] where f x xs = [x:xs,xs]
%ghc -c -O2 Test.hs %ghci
:l Test
Ok, modules loaded: Test.
:set +s
length $ mcombs [1..20] 1048576 (0.06 secs, 56099528 bytes)
length $ mcombs [1..50]
^CInterrupted.
Yes, 2^50 = 1125899906842624. If your computer generated 10^9 sublists per second, you'd wait more than ten days for the answer. Since something like 25 million - 100 million per second is more in the region of what ordinary computers can achieve, it'd rather be three months to over a year. Prelude Parts> mcombs [1 .. 50] !! 100000000 [1,2,3,4,5,6,7,8,10,11,12,13,18,20,26,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50] (4.35 secs, 5254369992 bytes) Prelude Parts> length $ replicate (10^8) () 100000000 (2.10 secs, 2806344336 bytes) Really, not bad, IMO.