Tom Pledger writes:
> Probably. Try replacing this
>(\z -> z <= (intsqrt x))
> with this
>(\z -> z^2 <= x)
Yes! This is significantly nicer. Taking 4000 primes, this is about twice
as fast as the original (loose) algorithm, and it appears that it gets
better as n grows. (Call this versio
On Wed, 23 Oct 2002, Jason Smith wrote:
> Hi All
>
> I don't know what I'm doing wrong here but for some reason no matter what esoteric
>command line option I seem to be able to dream up I can get ghc to include IOExts..I
>want to use the side-affect IO commands but cannot.
>
> I am using ghc-
Hi All
I don't know what I'm doing wrong here but for some
reason no matter what esoteric command line option I seem to be able to dream up
I can get ghc to include IOExts..I want to use the side-affect IO commands but
cannot.
I am using ghc-5.02.2 for Win32.
Can someone just give me a
G'day all.
On Thu, Oct 17, 2002 at 11:08:57AM -0400, [EMAIL PROTECTED] wrote:
> For an
> interpreter I'm writing, I found myself writing a function
> "constructVarExpr :: String -> Expr" just to make it easier.
As an alternative opinion, I don't think there's anything wrong
with this. A constru
> Variable (VVariable(varName, (Value (Number
> (NNumber (varValue, varDimension))
>
> Here VVariable and NNumber are newtype constructors of tuples, and the
> entire expression is an "Expression" which, among other things has:
>
> data Expression =
> V
Tom Pledger writes:
| Tim Otten writes:
| :
| | Can anyone suggest why the tighter algorithm exhibits significantly
| | worse performance? Is takeWhile significicantly more expensive than
| | take?
|
| No.
Correction (before anyone else pounces on it):
Only if the predicate function (
Tim Otten writes:
:
| Can anyone suggest why the tighter algorithm exhibits significantly
| worse performance? Is takeWhile significicantly more expensive than
| take?
No.
| Is the \z lambda expression expensive?
No.
| The intsqrt isn't recalculated each time takeWhile evalutes a
| prime
As a student in an undergraduate 'Intro to Discrete Structures' course, I
recently did a project which required generating the first n primes. We
discussed the sieve of Eratosthenes in class. Although the professor is
not familiar with Haskell, he allowed me to use it, and I
mistakenly wrote the fo
Frank Atanassow wrote (on 22-10-02 15:08 +0200):
> Jerzy Karczmarczuk wrote (on 22-10-02 13:05 +0200):
> > What do you think, what
> > is the Rational form of 2.3 ? (GHCi says 23/10).
> >
> > The answer is:
> >
> > 2589569785738035 % 1125899906842624
>
> Er, why?
>
> Because 2.3 is not represen
> applyEach [(+1), (+3), (+2)] 1
> => [2,4,3] :: [Integer]
>
> > applyEach' :: [a->b] -> a -> [b]
> > applyEach' funs x = map applyx funs where applyx (fun) = fun x
...or more simply:
applyEach' l x = map ($x) l
___
Haskell-Cafe mailing list
[EMAIL P
(I'm not sure why my postings seem somewhat anonymous, I'll mess with
the headers in this post to see if that fixes it. I post to other
mailman lists and haven't noticed this problem.)
I'm working through Paul Hudak's SOE, and have a question about
problem 9.4, which is to define a function apply
Thanks for your reply...
Paul Hudak <[EMAIL PROTECTED]> writes:
> > case expr of
> > C f -> ...
> > V (Variable (VVariable s)) -> ...
> > ...
>
> I think you mean:
>
> case expr of
> C f -> ...
> V (VVariable s) -> ...
>
> which is not quite as verbose.
Yes, I think I should h
"Simon Peyton-Jones" <[EMAIL PROTECTED]> writes:
> You look in the instance declaration for Ratio, which is
> given in the Ratio chapter of the Library report.
This is what I ignorantly called implementation. Sorry for
the trouble.
> As I understand it, GHC conforms to the Report, but Hugs
> pe
Jerzy Karczmarczuk wrote (on 22-10-02 13:05 +0200):
> What do you think, what
> is the Rational form of 2.3 ? (GHCi says 23/10).
>
> The answer is:
>
> 2589569785738035 % 1125899906842624
Er, why?
Because 2.3 is not representable using a double precision float or something?
--
Frank
_
| > The Report says that the Enum instance for Ratio uses the
| > same rule as for Float/Double,
|
| Now I can see that the revised Report contains more about
| this than the one on haskell.org. But I still can't see the
| statement you cited above. Where should I look?
You look in the instance
Jerzy Karczmarczuk <[EMAIL PROTECTED]> writes:
> Rationals in Hugs were always a bit obscure. What do you think, what
> is the Rational form of 2.3 ? (GHCi says 23/10).
> The answer is:
> 2589569785738035 % 1125899906842624
> (Old Hugs, Feb. 2001)
I'm afraid the new release won't fix this.
O
"Simon Peyton-Jones" <[EMAIL PROTECTED]> writes:
> The Report says that the Enum instance for Ratio uses the
> same rule as for Float/Double,
Now I can see that the revised Report contains more about
this than the one on haskell.org. But I still can't see the
statement you cited above. Where sh
The Report says that the Enum instance for Ratio uses the same rule as
for Float/Double, namely that
[a..b]
means
takeWhile (<= (b+1/2)) [a, a+1, a+2, ...]
You may say that the "<=" should be "<" but that's what the Report says.
Certainly if you do [1%3..10%3] you'll get more valu
Alastair Reid:
> Ferenc Wagner <[EMAIL PROTECTED]> writes:
> H, the CVS copy of Hugs seems to suffer from a different problem:
>
> Prelude> [0.5,1.5..5.5]::[Rational]
> [0 % 1,1 % 1,2 % 1,3 % 1,4 % 1,5 % 1]
>
> I'm expecting to see:
>
> [1 % 2,3 % 2,5 % 2,7 % 2,9 % 2,11 % 2]
Rationals in
Alastair Reid <[EMAIL PROTECTED]> writes:
> H, the CVS copy of Hugs seems to suffer from a different problem:
>
> Prelude> [0.5,1.5..5.5]::[Rational]
> [0 % 1,1 % 1,2 % 1,3 % 1,4 % 1,5 % 1]
Yes, the instance declaration misses the numericEnumFrom-
ThenTo case, so it defaults to this. Btw, ho
Ferenc Wagner <[EMAIL PROTECTED]> writes:
$ ghci
Prelude> :m Ratio
Ratio> [1%2..10%2]
> [1 % 2,3 % 2,5 % 2,7 % 2,9 % 2,11 % 2]
H, the CVS copy of Hugs seems to suffer from a different problem:
Prelude> [0.5,1.5..5.5]::[Rational]
[0 % 1,1 % 1,2 % 1,3 % 1,4 % 1,5 % 1]
I'm expecting to see:
With GHC-5.02.2, I do
$ ghci
Prelude> :m Ratio
Ratio> [1%2..10%2]
[1 % 2,3 % 2,5 % 2,7 % 2,9 % 2,11 % 2]
The question is, why is there 11%2 at the end of the list?
It's inconsistent with the (good) rules for Integer, since
Ratio> [1,3..10]
[1,3,5,7,9]
Is this intentional?
22 matches
Mail list logo