Hi
This was my original version plus some modifications as advised by the list:
f c = sum [1 | x - ['\0'..], x c]
The following version was sent by a list member:
f c = length $ takeWhile (c) ['\0'..]
Now, the sender asserted that the first version was much too slow.
I'm wondering how the
The second version looks very neat, certainly, though I am not
entirely convinced that it's any more efficient. Still, I may be
missing something.
The compiler must be one hell of a machine. I wonder if the source
code is available to the public.
Cheers, Paul
At 12:26 30/09/2007, you wrote:
On 9/30/07, PR Stanley [EMAIL PROTECTED] wrote:
Hi
This was my original version plus some modifications as advised by the list:
f c = sum [1 | x - ['\0'..], x c]
The following version was sent by a list member:
f c = length $ takeWhile (c) ['\0'..]
Now, the sender asserted that the first
Hi
filter :: (a - Bool) - [a] - [a]
filter f = foldr (\x - \xs - if (f x) then (x:xs) else xs) []
Somehow I feel this could be done more elegantly. What does the list think?
Thanks, Paul
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
The compiler must be one hell of a machine. I wonder if the source
code is available to the public.
It is, and it is. =)
http://hackage.haskell.org/trac/ghc/wiki/Building/GettingTheSources
-Brent
___
Haskell-Cafe mailing list
Perhaps a list comprehension better shows the intention of the filter function:
filter p xs = [x | x - xs, p x]
You can literally read that as take all x from xs that satisfy p.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
On 9/30/07, PR Stanley [EMAIL PROTECTED] wrote:
Hi
filter :: (a - Bool) - [a] - [a]
filter f = foldr (\x - \xs - if (f x) then (x:xs) else xs) []
Somehow I feel this could be done more elegantly. What does the list
think?
Thanks, Paul
Well, note that foldr takes a function of x, which
The question is asking for a new definition of filter using foldr.
Sorry, I should have mentioned that before.
Cheers, Paul
At 14:26 30/09/2007, you wrote:
Perhaps a list comprehension better shows the intention of the
filter function:
filter p xs = [x | x - xs, p x]
You can literally read
Hi
sumSquareEven = (sum.map (^2)).filter even
I wrote this thinking i was being very clever. The question is asking
to spot the error in
f = compose [sum, map (^2), filter even]
I've only seen [] used in list comprehension and initialisation.
I conducted a mini search on compose earlier but to
On 9/30/07, PR Stanley [EMAIL PROTECTED] wrote:
So the question is, does compose as a function or keyword exist in
Haskell and if so how can the above code frag be corrected?
O and, is compose in any way related to curry and uncurry?
You can't write that function in Haskell as the list is
Well, note that foldr takes a function of x, which produces a
function of xs. This function of xs either conses x onto it, or
leaves it unchanged. We can write this down explicitly by removing
the xs parameter and just writing what function should be produced:
filter f = foldr (\x - if (f
On Sep 30, 2007, at 11:57 , PR Stanley wrote:
Well, note that foldr takes a function of x, which produces a
function of xs. This function of xs either conses x onto it, or
leaves it unchanged. We can write this down explicitly by
removing the xs parameter and just writing what
filter f = foldr (\x - if (f x) then (x:) else id) []
That's one neat solution but it also raises a few questions for me:
foldr :: (a - b - b) - b - [a] - b
yet you've managed to squeeze in a function that takes only one argument. How
is this possible without GHCI blowing its top?
Someone
This is of course very easy to do manually, but does a command line tool
exist for extracting source code from literate Haskell files?
Thanks,
Peter
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
On Sep 30, 2007, at 14:39 , Peter Verswyvelen wrote:
This is of course very easy to do manually, but does a command line
tool exist for extracting source code from literate Haskell files?
unlit in the GHC library directory?
--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL
This is of course very easy to do manually, but does a command line tool
exist for extracting source code from literate Haskell files?
something like:
sed -e '/^[^]/d' -e 's/^//g' foo.lhs foo.hs
the first expression deletes lines not starting with . The
second expression removes the at
Peter Verswyvelen bf3 at telenet.be writes:
to do manually, but does a command line tool exist for extracting
source code from literate Haskell files?
Thanks,
Peter
lhs2tex will do this for you.
___
Haskell-Cafe mailing list
On 9/29/07, Ryan Ingram [EMAIL PROTECTED] wrote:
first bc = SF sf where
sf dt ~(b,d) = ((c,d), sfFirst bc') where
(c, bc') = runSF bc dt b
One question I had was about the implementation of first. Is it
important that the pair match be lazy? Or is it safe to make
Hi Guys!
According ghci the kind of (-) is ?? - ? - *
What do the '??' mean? What is the difference between the '?' and the '*'
Cheers
--
-Jeeva
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
On Mon, Oct 01, 2007 at 11:40:20AM +1000, jeeva suresh wrote:
Hi Guys!
According ghci the kind of (-) is ?? - ? - *
What do the '??' mean? What is the difference between the '?' and the '*'
It's an implementation detail leaking out. GHC uses a set of special
types to represent primitive
20 matches
Mail list logo