From: Eden Cardim on
> I am not interested in reading rudeness. Few readers are.
> What I presented is to encourage discussion, not to provide
> readers a chance to be rude.

Neither am I interested in writing rudeness, I'm interested in writing
facts, my apologies if they offend you. The discussion is supposed to
be technical (not personal), but eventually we all make mistakes. Due
to the lack of time, I didn't review my post as to not make it sound
rude.

> Anno did not code for the type of data I exemplified, nor is he expected to do so.

Precisely what I mentioned before.

> I have provided a reasonable "what if" situation which does not
> reflect the quality of Anno's code; his code is very nice.

Thank you, by the way, I had quite some fun testing sort and re-reading
it's documentation.

From: John Bokma on
"Purl Gurl" <purlgurl(a)purlgurl.net> wrote:

> Eden Cardim wrote:
>
>> You're mistaken
>> Wrong again,
>
> I am not interested in reading rudeness.

But have no problem in writing it...

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
I ploink googlegroups.com :-)

From: A. Sinan Unur on
"Feyruz" <feyruzyalcin(a)hotmail.com> wrote in
news:1133374143.449652.176400(a)g44g2000cwa.googlegroups.com:

> people, whats going on here. I just wanted to discuss an algorithm
> here, i did not want anyone to come here and be arrogant because he or
> she has more experience in programming language than others. I think
> some people like to fight over the internet.
> Purl Gurl, why dont you also behave more civilized before calling
> others rude?

Before you post in a newsgroup, you are expected to lurk for awhile. If
you had done that, or if you had looked at the archives, you would have
learned about PG's reputation.

In addition, it looks like you have not read the posting guidelines for
this newsgroup. Please do so, and please follow them. Your original post
followed all the guidelines, so that is a good thing. However, your
replies have omitted all context, and that is a bad thing.

> Anyway, thanks Lars, Anno and Xhos for your comments on my "stupid?"
> (according to Xhos) problem.
> F.

Xho's diagnosis was spot on: It is stupid to find a maximum using
recursion. It should never be done, even as a learning tool. On the
other hand, neither his nor my comments are directed to you personally,
and you should not take them so.

Sinan


--
A. Sinan Unur <1usa(a)llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

From: Purl Gurl on
Eden Cardim wrote:

> The problem is that the comparison will return the
> right-most element if the values are equal, since 'z' is numerically
> equivalent to 0, the value returned by max will depend on the position
> of the elements in the $right and $left variables, $right will always
> be returned when the values are equal.

> > @Array = qw (-10 -9 -8 -7 -6 0 -5 -4 -3 -2 -1 Z Y X W);

> If you sort this, you'll get W because it's the rightmost greater
> element in numeric context.

> > @Array = qw (Z Y X W -10 -9 -8 -7 -6 0 -5 -4 -3 -2 -1);

> If you sort this, you'll get W because it's the rightmost greater
> element in numeric context.

>> @Array = qw (-10 -9 -8 -7 -6 0 -5 -4 -3 -2 -1 W Y X Z);

> Now you'll get Z

What you write makes perfect sense; letters are evaluated to zero
in a numerical context. Which letter is returned as a zero value is
simply a coincidence of relative position, left versus right.

I tossed in a 1 within my test array, and 1 is correctly returned
as the "maximum" value in my array.

The code written by Anno will work when there is an element
with a value greater than zero.

#!perl

@Array = qw (-10 -9 -8 -7 -6 0 -5 -4 -3 -2 -1 1 W Y X 0 Z);

@Array = sort {$a <=> $b} @Array;

print "@Array";

That code verifies what you write is correct. That is a zero between
the letters X and Z in my array, and between -6 and -5 in my array.

Zero is correctly sorted within the negative numbers group, but is
tossed in with letters, strictly by the physical position of zero.

Purl Gurl
From: Jim Gibson on
In article <1133371616.571244.296370(a)f14g2000cwb.googlegroups.com>,
Eden Cardim <edencardim(a)gmail.com> wrote:

> The problem is that the comparison will return the
> right-most element if the values are equal, since 'z' is numerically
> equivalent to 0, the value returned by max will depend on the position
> of the elements in the $right and $left variables, $right will always
> be returned when the values are equal. That means the code is broken,
> and worse, I don't think it can be fixed because the code was meant to
> be run on numbers.

That is not quite true. The comparison will determine that the elements
being compared are equal. How the two elements end up in the final sort
order is determined by the "stability" of the sort. A sort which is
"stable" will retain the original order of equal elements. A sort which
is not stable is free to reorder equal elements.

According to 'perldoc -f sort', perl 5.6 and earlier used a non-stable
quicksort algorithm. Perl 5.7 and later use a stable mergesort
algorithm. Therefore, your results may vary depending upon which
version of perl you are using. There are also pragmas to affect the
sort algorithm used (e.g., "use sort 'stable'").

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5
Prev: Perl - Get Two Decimals
Next: How to declare a variable???