2d
comment Did we really have to delete this 80-vote community wiki answer after three years?
@GeorgeStocker what's your take on this (another) case? is the answer good enough to be preserved even though it is incomplete, and the question indeed off-topic? ( the question has almost 1500 views... and two of the deleters are the same as on this here question. )
Feb
26
revised Why does this Haskell code compile?
c/e
Feb
25
comment Sieve of Eratosthenes - Finding Primes Python
n for n in ilist if n%p != 0 tests each number n in a range for divisibility by p; but range(p*p, N, p) generates the multiples directly, all by itself, without testing all these numbers.
Feb
25
comment Interview question : What is the fastest way to generate prime number recursively?
@Charles thanks for the confirmation.
Feb
10
revised Haskell Arrow delay function
add missing code; formatting; c/e; retag
Feb
9
comment Haskell: Why can't I pattern match against function?
cf. en.wikipedia.org/wiki/….
Feb
9
revised What is the logic of this process
small fix for corner cases
Feb
8
comment Reverse list order without increasing complexity
you mean, let (yes, no)=r in ...? right; no need to. I actually answered an hour before you did, but the code turned out a near exact replica of the one in the library, so I deleted (users with 10k rep can see deleted answers, IIRC). You give a nice exposition here with the various variants.
Feb
8
comment Reverse list order without increasing complexity
you could use (yes,no) pattern in your last version, with where.
Feb
7
comment Reverse list order without increasing complexity
study the source code for partition: it effectively adds elements to the end of a list as it is being built (the both of them). Lazy pattern (the ~) allows for infinite list as an input (e.g. take 10 $ fst $ partition odd [1..]).
Feb
5
answered Recursive tail of power in prolog
Feb
5
comment Recursive tail of power in prolog
see if this answer clears things up, perchance.
Feb
5
comment Better algorithm on prime numbers
@Joel thanks for the edit, and I upvoted; I think now (sorry for that :) ) that better thing to do would be to divide by the actual running time, so it will be a horizontal line. Also, no need for N^(3/2), what's needed is N^(3/2)/(log N)^2. I've got a feeling this new line will become horizontal too, at some point. This would mean the run time is the same, up to a constant factor. This might be a nice alternative to calculating the power coefficients on consecutive ranges (as in WP article), as the constant factors find their expression too, here, unlike with that method.
Feb
4
revised How to solve task to study in prolog?
added 262 characters in body
Feb
4
comment How to solve task to study in prolog?
note for those voting to close: this is not about debugging.
Feb
4
answered How to solve task to study in prolog?
Feb
4
comment Why do we need monads?
@Mike only if f produces the boxed data, and you further "flatten" it down to one level of boxing after mapping. In Haskell, (Just 5) >>= (\x-> Just (2*x)) is the same as (`map` (Just 5)) (\x-> (2*x)). The two functions are different. It is Functors that have map.
Feb
4
comment Better algorithm on prime numbers
I suggest the additional scaling as maybe it will allow you to enhance the vertical resolution of the graph (or maybe it won't be necessary). I'd sure upvote this answer then.
Feb
4
comment Better algorithm on prime numbers
@Joel I have no way of knowing whether it is something new for you to discover, right? So it was necessarily oblique, but not a criticism at all, just an observation. :) The complexity of the new code with the added sqrt limit is N^1.5/(log N)^2, AFAICR. So no, that was not a small edit, not by any measure. -- It would be very interesting to see on that graph the run time for the original code (before the edit) too. Also, it might aid the visual comprehension of the graph if you would divide each line's data by N and scale each by some additional constant so they start at same point.
Feb
4
awarded Deputy
1 2 3 4 5