pref_eq k xs ys = take k xs == take k ys
This seems to be a straightforward implementation with good properties.
Actually, no, at least not if implemented naively.
I choosed this example, since I stumbled on this question last week.
Reputable mathematicians doing combinatorics on
take 1000 [1..3] still yields [1,2,3]
You can think about take n as: Take as much as possible, but at most n
elements. This behavior has some nice properties as turned out by
others, but there are some pitfalls. We have
length . take n /= const n
in general, instead only
length . take
Hi folks
On 12 Sep 2007, at 00:38, Brent Yorgey wrote:
On 9/11/07, PR Stanley [EMAIL PROTECTED] wrote: Hi
take 1000 [1..3] still yields [1,2,3]
I thought it was supposed to return an error.
[..]
If for some reason you want a version that does return an error in
that situation, you could
On Wed, 12 Sep 2007, Conor McBride wrote:
Hi folks
On 12 Sep 2007, at 00:38, Brent Yorgey wrote:
On 9/11/07, PR Stanley [EMAIL PROTECTED] wrote: Hi
take 1000 [1..3] still yields [1,2,3]
I thought it was supposed to return an error.
[..]
If for some reason you want a version that does
One idiom I rely on pretty often is
(id tail) uncurry (zipWith f)
to do pairwise binary operations (though I suspect an Applicative
functor might be a better way to go?).
E.g. my solution for ProjectEuler problem #18 (max sum of vertical path
through a triangle of integers) is:
f =
On 12 Sep 2007, at 8:08 pm, [EMAIL PROTECTED] wrote:
take 1000 [1..3] still yields [1,2,3]
You can think about take n as: Take as much as possible, but at
most n elements. This behavior has some nice properties as turned
out by others, but there are some pitfalls.
One of the very nice
On 9/11/07, PR Stanley [EMAIL PROTECTED] wrote:
Hi
take 1000 [1..3] still yields [1,2,3]
I thought it was supposed to return an error.
Any ideas?
No, that's the behavior for take specified in the Haskell 98 report:
http://haskell.org/onlinereport/standard-prelude.html
-- take n, applied to a
On 9/11/07, PR Stanley [EMAIL PROTECTED] wrote:
Hi
take 1000 [1..3] still yields [1,2,3]
I thought it was supposed to return an error.
Any ideas?
Thanks, Paul
If for some reason you want a version that does return an error in that
situation, you could do something like the following:
I suppose I'm thinking of head or tail - e.g. head [] or tail [].
I'm trying to write my own version of the find function. I have a few
ideas but not quite sure which would be more suitable in the context of FP.
Any advice would be gratefully received - e.g. do I use recursion,
list
byorgey:
On 9/11/07, PR Stanley [EMAIL PROTECTED] wrote:
Hi
take 1000 [1..3] still yields [1,2,3]
I thought it was supposed to return an error.
Any ideas?
Thanks, Paul
If for some reason you want a version that does return an error in that
situation,
On 9/11/07, Don Stewart [EMAIL PROTECTED] wrote:
byorgey:
On 9/11/07, PR Stanley [EMAIL PROTECTED] wrote:
Hi
take 1000 [1..3] still yields [1,2,3]
I thought it was supposed to return an error.
Any ideas?
Thanks, Paul
If for some reason you want a
On Tue, Sep 11, 2007 at 07:38:18PM -0400, Brent Yorgey wrote:
On 9/11/07, PR Stanley [EMAIL PROTECTED] wrote:
Hi
take 1000 [1..3] still yields [1,2,3]
I thought it was supposed to return an error.
Any ideas?
Thanks, Paul
If for some reason you want a version that does return an
Let me get this right, are you saying it's unsafe when it returns an error?
Paul
At 00:40 12/09/2007, you wrote:
byorgey:
On 9/11/07, PR Stanley [EMAIL PROTECTED] wrote:
Hi
take 1000 [1..3] still yields [1,2,3]
I thought it was supposed to return an error.
Any
prstanley:
I suppose I'm thinking of head or tail - e.g. head [] or tail [].
I'm trying to write my own version of the find function. I have a few
ideas but not quite sure which would be more suitable in the context of
FP.
Any advice would be gratefully received - e.g. do I use
byorgey:
On 9/11/07, Don Stewart [EMAIL PROTECTED] wrote:
byorgey:
On 9/11/07, PR Stanley [EMAIL PROTECTED] wrote:
Hi
take 1000 [1..3] still yields [1,2,3]
I thought it was supposed to return an error.
Any ideas?
prstanley:
Let me get this right, are you saying it's unsafe when it returns an
error?
Partial functions may crash your program, so that's unsafe by some definitions,
yep.
We have tools that analyse programs for such bugs, in fact (Neil's `catch'
program).
-- Don
On Tue, 2007-09-11 at 16:48 -0700, Don Stewart wrote:
byorgey:
On 9/11/07, Don Stewart [EMAIL PROTECTED] wrote:
byorgey:
On 9/11/07, PR Stanley [EMAIL PROTECTED] wrote:
Hi
take 1000 [1..3] still yields [1,2,3]
I thought it
17 matches
Mail list logo