Re: exercise: partition a list by equivalence
John Lenton wrote:[color=blue]
> On Fri, Feb 18, 2005 at 04:52:46PM -0800, John Machin wrote:[color=green][color=darkred]
> > > > needs "if rev[first] == rev[second]: continue" here
> > >
> > > an 'is' is enough, and better.[/color]
> >
> > Good point. You're redeeming yourself :-)[/color]
>
> this, together with you saying that it is hard to explain, makes me
> think that you aren't comfortable thinking of lists as mutable
> objects.[/color]
How so? There is no connection between is/== and mutability. Let me
amplify: The point about 'is' is a good one, and aids your redemption
after your failure to have adequate guards caused your algorithm not to
work.
[color=blue]
>
>[color=green][color=darkred]
> > > what is magic about it? is it really that horrible?[/color]
> >
> > Try explaining to the newbies over on the tutor list how despite[/color][/color]
"res"[color=blue][color=green]
> > only ever *explicitly* having little bits like [3, 4] appended to[/color][/color]
it,[color=blue][color=green]
> > it (or more properly the thing to which it refers) is actually
> > festering and growing and being mutated under the surface until at[/color][/color]
the[color=blue][color=green]
> > finale it bursts out dripping slime just like the creature from the
> > black lagoon ...[/color]
>
> understanding why that works, and why it is 'is' and not '==', are
> both part of the same thing.[/color]
What same thing is that?
[color=blue]
> Lists are mutable, and you can mutate
> them, and they mutate. Unless you actually write code that uses the
> fact you will forget it, and it will bite you. Of course, don't use[/color]
it[color=blue]
> just for the heck of it, but that creature you dismiss as a
> slime-dripping mutation is actually quite useful.[/color]
You are confusing mutability of lists (without which they would be
called tuples!) with my point that the 'res' list was having its
contents fiddled with implicitly through other "pointers".
[color=blue]
>
> While I'm at being unpolite, do you really think this code was harder
> to understand than the code posted by anton, using numarray?[/color]
I only read it as far as the bit where it creating a matrix of size
O(N**2) -- in my app N can be over a million so I lost interest
rapidly.
[color=blue]
>
> And, of course, if this code were for anything non-throw-awayable,
> there would've been quite a bit of explaining going on between those
> lines of code.
>[/color]
Not of course, but of necessity.
[color=blue]
> Ok, now back to being polite :)[/color]
Welcome back.
John Lenton wrote:[color=blue]
> On Fri, Feb 18, 2005 at 04:52:46PM -0800, John Machin wrote:[color=green][color=darkred]
> > > > needs "if rev[first] == rev[second]: continue" here
> > >
> > > an 'is' is enough, and better.[/color]
> >
> > Good point. You're redeeming yourself :-)[/color]
>
> this, together with you saying that it is hard to explain, makes me
> think that you aren't comfortable thinking of lists as mutable
> objects.[/color]
How so? There is no connection between is/== and mutability. Let me
amplify: The point about 'is' is a good one, and aids your redemption
after your failure to have adequate guards caused your algorithm not to
work.
[color=blue]
>
>[color=green][color=darkred]
> > > what is magic about it? is it really that horrible?[/color]
> >
> > Try explaining to the newbies over on the tutor list how despite[/color][/color]
"res"[color=blue][color=green]
> > only ever *explicitly* having little bits like [3, 4] appended to[/color][/color]
it,[color=blue][color=green]
> > it (or more properly the thing to which it refers) is actually
> > festering and growing and being mutated under the surface until at[/color][/color]
the[color=blue][color=green]
> > finale it bursts out dripping slime just like the creature from the
> > black lagoon ...[/color]
>
> understanding why that works, and why it is 'is' and not '==', are
> both part of the same thing.[/color]
What same thing is that?
[color=blue]
> Lists are mutable, and you can mutate
> them, and they mutate. Unless you actually write code that uses the
> fact you will forget it, and it will bite you. Of course, don't use[/color]
it[color=blue]
> just for the heck of it, but that creature you dismiss as a
> slime-dripping mutation is actually quite useful.[/color]
You are confusing mutability of lists (without which they would be
called tuples!) with my point that the 'res' list was having its
contents fiddled with implicitly through other "pointers".
[color=blue]
>
> While I'm at being unpolite, do you really think this code was harder
> to understand than the code posted by anton, using numarray?[/color]
I only read it as far as the bit where it creating a matrix of size
O(N**2) -- in my app N can be over a million so I lost interest
rapidly.
[color=blue]
>
> And, of course, if this code were for anything non-throw-awayable,
> there would've been quite a bit of explaining going on between those
> lines of code.
>[/color]
Not of course, but of necessity.
[color=blue]
> Ok, now back to being polite :)[/color]
Welcome back.
Comment