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 =
seqList rwhnf(map f ry)
()
(4.48 secs, 833668720 bytes)
*Main seqList rwhnf(map f ry)
()
(3.18 secs, 627071612 bytes)
*Main
Arie Groeneveld schreef:
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
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
result
(x.xx secs, yyy bytes)
Are there any hidden difficulties involved?
Reason is:
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
Reinier Lamers schreef:
printint :: Int - [Char]
printint = map chr . map (+0x30) . reverse . map (`mod` 10) .
takeWhile (0) . iterate (`div`10)
Most of the time I use this:
digits :: Integer - [Int]
digits = map (flip(-)48.ord) . show
Regards
=@@i
Steve Schafer wrote:
x = a - sqrt(a^2 - b^2)
I don't know offhand if there's a straightforward way to arrive at this
result without using trigonometry.
Here you go, though with a slightly different result
(same as Joel Koerwer):
a^2=(b^2)/4+(a-x)^2 (Pythagoras)
solving x: --
x(1,2) = a
Correction
stefan a b = a - a * sqrt (1 - b*b / a*a)
should be:
stefan a b = a - a * sqrt (1 - b*b / (a*a))
*Main stefan 10 8
4.0
(0.01 secs, 524896 bytes)
Thanks
@@i
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Hi,
I defined several functions for calculating the number
of trailing zero's of n!
tm = sum . takeWhile(0) . iterate f . f
where f = flip div 5
tm1 n = sum . takeWhile(0) . map (div n . (5^)) $ [1..]
tm2 n = sum . takeWhile(0) . map (div n) $ iterate ((*)5) 5
tm3 = sum . takeWhile(0) .
Bjorn Bringert wrote:
Here's a much more inefficient version, but it has the merit of being
very easy to understand:
tm_silly n = length $ takeWhile (=='0') $ reverse $ show $ product [1..n]
You're rigth. I came up with that one too the first time. But for large
value's of n
it
Thanks for all the instructive replies
and alternatives! Learned a bit more in
terms of feeling about style and improvement
of some of the functions: f.e. 'killing'
the 'where' in my number one choice.
Thanks
@@i
___
Haskell-Cafe mailing list
Henning Thielemann wrote:
tm4 = sum . takeWhile(0) . tail . iterate (flip div 5)
FWIW: as a result of all this I learned to write this as:
tm41 = sum . takeWhile(0) . tail . iterate (`div` 5)
@@i
___
Haskell-Cafe mailing list
Hi,
I don't know if this is the right place to post this, but here I go.
I translated a BC-program found on the home page of Keith Matthews,
http://www.numbertheory.org/keith.html.
It's about the expension of a (not necessarily reduced) fraction m/n in
base b.
Looking at the result of my
I tried this version,
however
nsortBy cmp l = mergesort compare l
should be:
nsortBy cmp l = mergesort cmp l
Thanks
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
I tried this version,
however
nsortBy cmp l = mergesort compare l
should be:
nsortBy cmp l = mergesort cmp l
Thanks
Sorry, with this version I meant:
nsort l = mergesort compare l
nsortBy cmp l = mergesort compare l
mergesort :: (a - a - Ordering) - [a] - [a]
mergesort cmp =
Miguel Mitrofanov wrote:
AG Wondering about time space consuming: 'nub' vs 'map
AG head.group.sort'
Prelude :t Data.List.nub
Data.List.nub :: (Eq a) = [a] - [a]
Prelude :t Data.List.sort
Data.List.sort :: (Ord a) = [a] - [a]
nub uses less information than sort, so it MUST be slower.
Ok,
Hi all,
I read this on the J -programming forum
http://www.jsoftware.com/pipermail/programming/2007-June/007004.html
Maybe of interest, especially the part of generating the subgroup or
composing a more intelligent solver.
quote
I found an interesting game, as found on Andrew Nikitin's
16 matches
Mail list logo