On Thu, Oct 19, 2006 at 04:03:38PM +0200, Mikael Johansson wrote:
> isIdentity (PL xs) = all (\(i,j) -> i==j) (zip [1..] xs)
>
> isIdentity (PL xs) = xs == [1..(length xs)]
How about a compromise?
isIdentity (PL xs) = xs == zipWith const [1..] xs
Best regards
Tomasz
It's nice to have that pointed out; I'm always forgeting that there's
a representation optimization going on when using Ints/Integers for
naturals.
This Peano approach makes the length check no longer strict in the
spine of its input. xs is consumed lazily, [1..natLength xs] is
produced lazily, a
David House wrote:
On 19/10/06, Brandon Moore <[EMAIL PROTECTED]> wrote:
isIdentity xs = xs == takeLengthOf xs [1..]
where takeLengthOf xs ys = zipWith const ys xs
You probably mean zipWith (flip const) xs ys.
Either way, as long as I didn't write "zipWith const xs ys".
for finite lists,
ta
On Thu, 19 Oct 2006, Tomasz Zielonka <[EMAIL PROTECTED]> wrote:
> On Thu, Oct 19, 2006 at 01:37:16PM -0400, Cale Gibbard wrote:
>
>> In order to determine if [1..length xs] has an element at all, you
>> have to evaluate length xs, which involves forcing the entire spine of
>> xs, because integers
On 19/10/06, Brandon Moore <[EMAIL PROTECTED]> wrote:
isIdentity xs = xs == takeLengthOf xs [1..]
where takeLengthOf xs ys = zipWith const ys xs
You probably mean zipWith (flip const) xs ys.
for finite lists,
takeLengthOf xs ys == take (length xs) ys
This ruins the laziness again:
Hugs.Ba
Nicolas Frisby wrote:
I may have missed this in the discussion so far, but it seems we could
use a summary.
In short: isIdentity does not check for exact equivalence, only a
prefix equivalence. That's why it doesn't exhibit the same time/space
behavior as a reformulation based on full equivalenc
I may have missed this in the discussion so far, but it seems we could
use a summary.
In short: isIdentity does not check for exact equivalence, only a
prefix equivalence. That's why it doesn't exhibit the same time/space
behavior as a reformulation based on full equivalence.
More verbosely: isI
On Thu, Oct 19, 2006 at 01:37:16PM -0400, Cale Gibbard wrote:
> >Why is this so? I'd have thought that the equality function for lists
> >only forces evaluation of as many elements from its arguments as to
> >determine the answer.
>
> In order to determine if [1..length xs] has an element at all,
On Oct 19, 2006, at 12:51 PM, David House wrote:
On 19/10/06, Mikael Johansson <[EMAIL PROTECTED]> wrote:
isIdentity xs = all (\(i,j) -> i==j) (zip [1..] xs)
isIdentity' xs = xs == [1..(length xs)]
Then
isIdentity 1:3:2:[4..10]
finishes in an instant, whereas
isIdentity' 1:3:2:[4..10]
On 19/10/06, David House <[EMAIL PROTECTED]> wrote:
On 19/10/06, Mikael Johansson <[EMAIL PROTECTED]> wrote:
> isIdentity xs = all (\(i,j) -> i==j) (zip [1..] xs)
> isIdentity' xs = xs == [1..(length xs)]
>
> Then
> isIdentity 1:3:2:[4..10]
> finishes in an instant, whereas
> isIdentity' 1:3:
On 19/10/06, Mikael Johansson <[EMAIL PROTECTED]> wrote:
isIdentity xs = all (\(i,j) -> i==j) (zip [1..] xs)
isIdentity' xs = xs == [1..(length xs)]
Then
isIdentity 1:3:2:[4..10]
finishes in an instant, whereas
isIdentity' 1:3:2:[4..10]
takes noticable time before completing.
Why is th
On Thu, 19 Oct 2006, Mikael Johansson wrote:
> On Thu, 19 Oct 2006, Mikael Johansson wrote:
> > Comparing the code for permutationgropus at
> > http://www.polyomino.f2s.com/david/haskell/codeindex.html
> > with my own thoughts on the matter, I discover the one line to figure out
> > whether a spe
On Thu, 19 Oct 2006, Mikael Johansson wrote:
Comparing the code for permutationgropus at
http://www.polyomino.f2s.com/david/haskell/codeindex.html
with my own thoughts on the matter, I discover the one line to figure out
whether a specific list represents the identity:
isIdentity (PL xs) = al
Hello Andrea,
Wednesday, October 18, 2006, 9:34:28 PM, you wrote:
> solution? Or just some hints on the kind of problem I'm facing: is it
> related to strictness/laziness, or it's just that I did not understand
> a single bit of how garbage collection works in Haskell?
i think, the second. unfor
On Oct 18, 2006, at 8:47 AM, Robert Dockins wrote:
On Oct 17, 2006, at 1:46 PM, Gregory Wright wrote:
On Oct 17, 2006, at 1:07 PM, Robert Dockins wrote:
On Oct 17, 2006, at 12:55 PM, Gregory Wright wrote:
Hi Rob,
I've built Edison 1.2.0.1 using ghc-6.6. (I'm testing the
macports,
Comparing the code for permutationgropus at
http://www.polyomino.f2s.com/david/haskell/codeindex.html
with my own thoughts on the matter, I discover the one line to figure out
whether a specific list represents the identity:
isIdentity (PL xs) = all (\(i,j) -> i==j) (zip [1..] xs)
Is there a
On Wed, Oct 18, 2006 at 04:42:00PM +0100, Simon Marlow wrote:> So you won't be able to colour patterns differently from expressions, that
> doesn't seem any worse than the context vs. type issue. Indeed, I'm not> even sure you can colour types vs. values properly, look at this:>> data T = C [Int
I want to thanks you all for your helps regarding this issue. You've been
very helpful and comprehensive.
Salute !!
--
Víctor A. Rodríguez (http://www.bit-man.com.ar)
El bit Fantasma (Bit-Man)
Perl Mongers Capital Federal (http://cafe.pm.org/)
GNU/Linux User Group - FCEyN - UBA (http://glugcen.dc.
| just one more problem is that this issue is too complicated. i'm not
| sure that i correctly understands details, but for me the situation
| seems like this: in 6.4 it was no distinction between declarations and
| usages of type variables - first use declared it, while in 6.6 we have
| exactly de
Sorry, I realized that it does not cover the
shorter [1..5] (shorter [2..] [3..])
case...
Eugene Crosser wrote:
> On Tue, 10 Oct 2006 [EMAIL PROTECTED] wrote:
>> Hi all,
>> I'm trying to implement a function that returns the shorter one of two given
>> lists,
>> something like
>> shorter :: [a]
On Tue, 10 Oct 2006 [EMAIL PROTECTED] wrote:
> Hi all,
> I'm trying to implement a function that returns the shorter one of two given
> lists,
> something like
> shorter :: [a] -> [a] -> [a]
> such that shorter [1..10] [1..5] returns [1..5],
> and it's okay for shorter [1..5] [2..6] to return eithe
21 matches
Mail list logo