Acc. to Luke Palmers suggestion this will be the right answer?
*Main> seqList rwhnf(map f $ concat.replicate 100 $ unfoldr (knip 6) an)
()
(3.46 secs, 834240864 bytes)
or with/without list construction
*Main> let ry = concat.replicate 100 $ unfoldr (knip 6) an
(0.00 secs, 0 bytes)
*Mai
Thanks for all the advises so far.
Ok, here's my monster that need to be timed in order to make a comparison:
(it's about the control digit of SEDOL numbers
http://en.wikipedia.org/wiki/SEDOL ):
knip _ [] = Nothing
knip k xs = Just (splitAt k xs)
ip xs = sum . zipWith (*) xs
an = ['0'..'9
bradypus:
> Suppose I've:
>
> f = map g
>
> I want to know how much time it takes (interpreted mode) to fully
> process list xs (at least 1e6 elements) with function g. Is it
> sufficient to execute:
>
> *Main> last . f $ xs
>
> (x.xx secs, yyy bytes)
>
> Are there any hidden difficu
On Sun, Aug 3, 2008 at 11:06 AM, Arie Groeneveld <[EMAIL PROTECTED]> wrote:
> Sorry, should go the forum.
>
> Ok, thanks. In this case the list consists of 6-digit alphanumeric
> codes. So doing something like:
>
> foldl1 (\x y -> g y) xs
No, that still doesn't force elements. Let's say g is (+
Arie,
foldl1 is not strict in its function argument. Using it will cause stack
overflows for large lists.
For example:
GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
Prelude> foldl1 (+) [0..100]
*** Exception: stack overflow
foldl1
Sorry, should go the forum.
Ok, thanks. In this case the list consists of 6-digit alphanumeric
codes. So doing something like:
foldl1 (\x y -> g y) xs
will do the job?
=@@i
Bulat Ziganshin schreef:
Hello Arie,
Sunday, August 3, 2008, 1:56:43 PM, you wrote:
*Main>> last . f $ xs
this way
Hello Arie,
Sunday, August 3, 2008, 1:56:43 PM, you wrote:
*Main>> last . f $ xs
this way you will get only "spin" of list computed, not elements
itself. something like sum should be used instead
--
Best regards,
Bulatmailto:[EMAIL PROTECTED]
Suppose I've:
f = map g
I want to know how much time it takes (interpreted mode) to fully
process list xs (at least 1e6 elements) with function g. Is it
sufficient to execute:
*Main> last . f $ xs
(x.xx secs, yyy bytes)
Are there any hidden difficulties involved?
Reason is: compar