K
kj
This question is not about Perl per se, but about computer science
history.
In the Perl world, the term "Schwartzian Transform" (named after
Perl guru Randal Schwartz, author of the popular book Learning
Perl, among others, and numerous articles and internet postings)
is used to denote the tag-sort-untag strategy illustrated here:
my @sorted =
map $_->[0],
sort {$a->[1] cmp $b->[1]}
map [$_, expensive_function($_)],
@unsorted;
Now, I realize that Mr. Schwartz did not name this procedure after
himself, but rather someone else did. Still, I find it hard to
believe that he was the first person to make public the use of this
technique. After all, there is a very similar technique, which
I've seen referred to as "tag shuffling", for randomly shuffling
a list. In Perl it would be rendered like this:
my @shuffled =
map $_->[0],
sort {$a->[1] <=> $b->[1]}
map [$_, rand()],
@array;
This is basically an ST in which "expensive_function" is replaced
by rand().
I've seen mentions of this shuffling technique in sources much
older than Perl (maybe older than Mr. Schwartz). Given the similarity
of this technique with the general ST, I suspect that the credit
for inventing goes to some prior author. Can anyone confirm this
suspicion?
BTW, I have nothing but respect, admiration, and gratitude for
Randal Schwartz. From his writings and postings I know that he is
easily sharp and creative enough to have invented this technique
independently on his own, even if it had been invented earlier.
Moreover, as I've already pointed out, he did not give his own name
to the technique.
Nonetheless, I am intrigued by its origins.
kj
history.
In the Perl world, the term "Schwartzian Transform" (named after
Perl guru Randal Schwartz, author of the popular book Learning
Perl, among others, and numerous articles and internet postings)
is used to denote the tag-sort-untag strategy illustrated here:
my @sorted =
map $_->[0],
sort {$a->[1] cmp $b->[1]}
map [$_, expensive_function($_)],
@unsorted;
Now, I realize that Mr. Schwartz did not name this procedure after
himself, but rather someone else did. Still, I find it hard to
believe that he was the first person to make public the use of this
technique. After all, there is a very similar technique, which
I've seen referred to as "tag shuffling", for randomly shuffling
a list. In Perl it would be rendered like this:
my @shuffled =
map $_->[0],
sort {$a->[1] <=> $b->[1]}
map [$_, rand()],
@array;
This is basically an ST in which "expensive_function" is replaced
by rand().
I've seen mentions of this shuffling technique in sources much
older than Perl (maybe older than Mr. Schwartz). Given the similarity
of this technique with the general ST, I suspect that the credit
for inventing goes to some prior author. Can anyone confirm this
suspicion?
BTW, I have nothing but respect, admiration, and gratitude for
Randal Schwartz. From his writings and postings I know that he is
easily sharp and creative enough to have invented this technique
independently on his own, even if it had been invented earlier.
Moreover, as I've already pointed out, he did not give his own name
to the technique.
Nonetheless, I am intrigued by its origins.
kj