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) .
On Aug 24, 2007, at 9:18 , Arie Groeneveld wrote:
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
On Aug 23, 2007, at 3:34 , Rich Neswold wrote:
On 8/22/07, Ian Lynagh [EMAIL PROTECTED] wrote:
On Wed, Aug 22, 2007 at 01:27:00PM -0500, Rich Neswold wrote:
newtype App a = App (ReaderT Connection (CGIT IO) a)
deriving (Monad, MonadIO, MonadReader Connection)
Unfortunately, when
when trying to build the latest cabal from darcs,
I got
[EMAIL PROTECTED]:~/src/cabinstall/cabal$ runghc Setup.lhs configure
Distribution/Simple.hs:110:7:
Could not find module `System.FilePath':
it was found in multiple packages: filepath-1.0 FilePath-0.11
[EMAIL
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
On Fri, 24 Aug 2007, Arie Groeneveld wrote:
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
This is very elegant! You could also inline 'f'
tm4 = sum . takeWhile(0) . tail . iterate (flip div 5)
Henning Thielemann wrote:
I like to write documentation comments like
fix ::
( a {- ^ local argument -}
- a {- ^ local output -} )
- a {- ^ global output -}
but Haddock doesn't allow it. Or is there a trick to get it work?
Haddock only supports documenting the top-level
tm = sum . takeWhile(0) . iterate f . f
where f = flip div 5
Quite nice. I like
tm5 0 = 0
tm5 n = let q = div n 5 in q + tm5 q
This version corresponds to what I'm think when parsing |tm|, so I wrote
it down directly.
Also possible
tm6 = sum . unfoldr ( \ n - case div n 5 of
| From the ghc manual:
|
| ---
| 7.3.3. The recursive do-notation
| ...
|
| It is unfortunate that the manual does not give the translation rules, or at
| least the translation for the given example.
Hmm. OK. I've improved the manual with a URL to the main paper
Marc A. Ziegert [EMAIL PROTECTED]
tm_parallelizable_v1 = \n - sum . takeWhile (0) $ map (div n) fives
where fives = iterate (*5) 1
tm_improved_v1 n = sum . takeWhile (0) $ iterate (div `flip` 5) (div n 5)
tm_fastestIMHO n = let m=div n 5 in if m5 then m else m+tm_fastestIMHO m
Hi
I'm new to WinHugs, what's wrong with isUpper of my WinHugs?
Nothing. The book/tutorial you are going from is out of date. Before
using the isUpper/isLower functions you first have to type :load
Char:
Hugs :load Char
Hugs filter isUpper ABCDEfgh
ABCDE
The :load Char loads the Char module
I’m currently playing around with SOE to make some simple interactive math
exercises for students. This worked fine, although I could have done this
much faster using C# (which I know very well), but since I’m addicted to
Haskell now, I used the latter language ;) Furthermore, I hope that one day,
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
Thomas Girod wrote:
class (Eq n, Eq e) = Topo a n e where
empty:: a
empty does not allow to infer the types n and e
nodes:: a - [n]
also nodes leaves the type e undetermined
http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#functional-dependencies
Thomas Girod wrote:
Hi there.
I'm trying to define a generic graph type here and don't understand on
one error I get. Here I come.
module Graph
where
class (Eq n, Eq e) = Topo a n e where
empty:: a
nodes:: a - [n]
edges:: a - [e]
This does not work
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
Unfortunately
http://www.cse.ogi.edu/~mpj/pubs/fundeps.html
is broken.
http://web.cecs.pdx.edu/~mpj/pubs/fundeps.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Hi Peter,
The OpenGL/GLUT bindings support all the things you would want, but it's a
bit too much pain for first year students.
For the last couple of years at the ANU (Australian National University,
Canberra) we've been using a front end library that I wrote which is similar
to SOE/HGL
Arie Groeneveld wrote:
tm = sum . takeWhile(0) . iterate f . f
where f = flip div 5
Which one is the most elegant one generally speaking?
I like that tm only uses div.
My personal choice is 'tm'.
I like 'tm3' (a revised version of tm2) in terms of
pointlessness and not having a
-BEGIN PGP SIGNED MESSAGE-
Hash: RIPEMD160
I'm toying around with web programming in Haskell. I'm trying to write a
script which GETs an id and returns a couple of random numbers.
Something like this:
cgiMain :: CGI CGIResult
cgiMain = do
inp - getInput id
let gen = parse
Adrian Neumann wrote:
Now I'd like to get a new StdGen, in case no id was supplied to the script.
parse :: Maybe String- IO StdGen
parse (Just x) = return $ read x
parse Nothing = getStdGen
Obviously this doesn't work because I'm trying to do IO inside CGI
(right?). Is there some incantation
2007/8/24, Adrian Neumann [EMAIL PROTECTED]:
Obviously this doesn't work because I'm trying to do IO inside CGI
(right?). Is there some incantation I can perform to make this possible?
Like
gen - arcaneMagic parse inp
As doing IO in the CGI Monad is a current need, it's an instance of
Simon Peyton-Jones wrote:
| It is unfortunate that the [ghc] manual does not give the translation
rules, or at
| least the translation for the given example.
Hmm. OK. I've improved the manual with a URL to the main paper
http://citeseer.ist.psu.edu/erk02recursive.html
which is highly
Benjamin Franksen wrote:
Simon Peyton-Jones wrote:
| It is unfortunate that the [ghc] manual does not give the translation
rules, or at
| least the translation for the given example.
Hmm. OK. I've improved the manual with a URL to the main paper
Shiqi Cao wrote:
Check out this
http://www.cas.mcmaster.ca/~kahl/HOPS/
http://www.cas.mcmaster.ca/%7Ekahl/HOPS/
Heh. I was thinking about trying to build something *exactly like* this...
OOC, how the heck did they make it work through a document interface?
Surely that's impossible?
Hi,
I am trying to install Haskellnet. But the configuration breaks on
dependency of network-any in GHC 6.6.
I thought network-any was part of Hierarchical libraries?
If not where do I get it?
Edaward.
___
Haskell-Cafe mailing list
On 8/24/07, Bjorn Bringert [EMAIL PROTECTED] wrote:
On Aug 23, 2007, at 3:34 , Rich Neswold wrote:
Bingo! Method #3 works beautifully! I missed the using-lift-with-
the-constructor permutation.
Thanks for your help!
I started writing a tutorial for Haskell web programming with the cgi
whops... i did check it, but
that was a copypaste mistake.
buggy:
tm_parallelizable_v1 = \n - sum . takeWhile (0) $ map (div n) fives
where fives = iterate (*5) 1
should be:
tm_parallelizable_v1 = \n - sum . takeWhile (0) $ map (div n) fives
where fives = iterate (*5) 5
- marc
28 matches
Mail list logo