Re: Schwartzian Transform

2001-03-22 Thread John Porter

Zenon Zabinski wrote:
 Personally, I have never used the Schwartzian Transform ...
 so I may not be fully knowledgeable of its usefulness. 
 
 do you need to understand the 
 intricacies if you can just cut and paste and just change a few 
 variables? 

Not to be harsh, but you probably *do* need to understand
the "intracacies" of the ST if you want to be able to
contribute usefully to the resolution of this issue.

-- 
John Porter




Re: Schwartzian Transform

2001-03-22 Thread Randal L. Schwartz

 "Brent" == Brent Dax [EMAIL PROTECTED] writes:

Brent   @s = schwartzian(

Please, if we're going to add an operator, let's not call it schwartzian!
I have enough trouble already telling people how to spell my name. :)

Maybe I should have a kid named "Ian", so I can see on a roster some day:

Schwartz,Ian

:-)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: Schwartzian Transform

2001-03-22 Thread Dan Brian

Could someone summarize the arguments for such an operator? Doing so, to
me, seems to subtrack from the scripting domain something which belongs
there. Teaching the transform in classes is a wonderful way to both
illustrate the power of Perl's map, and more importantly, help programmers
understand the beauty of compact Perl. I'd hate to see that relegated to
the "how-we-used-to-do-it" column in the name of making it easier.

IMO the very quest for a name would be reason enough to not do it.
"map_sort_map"? That begs the question. And since Randal asks that it not
be named after him ... (I heard he filed a trademark on Schwartzian, so
that's out. :)

On 22 Mar 2001, Randal L. Schwartz wrote:

  "Brent" == Brent Dax [EMAIL PROTECTED] writes:
 
 Brent   @s = schwartzian(
 
 Please, if we're going to add an operator, let's not call it schwartzian!
 I have enough trouble already telling people how to spell my name. :)
 
 Maybe I should have a kid named "Ian", so I can see on a roster some day:
 
 Schwartz,Ian
 
 :-)
 
 -- 
 Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
 See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
 




Re: Schwartzian Transform

2001-03-22 Thread Uri Guttman

 "RLS" == Randal L Schwartz [EMAIL PROTECTED] writes:

  RLS sort { $a/$b expression } { transforming expression, glued with $_ } @list

  RLS so $a-[0] is guaranteed to be the original element, and the list-return
  RLS value of the second block becomes $a-[1]... $a-[$#$a].

  RLS So, to sort case insensitive (bad example :):

  RLS @sorted = sort { $a-[1] cmp $b-[1] } { uc } @list;

  RLS or to sort on GCOS and then username of password lines:

  RLS @sorted = sort { $a-[5] cmp $b-[5] or $a-[1] cmp $b-[1] }
  RLS { split /:/ } `cat /etc/passwd`;

  RLS That captures the canonical ST pretty well, where $a-[0] is always
  RLS the original element.

what everyone is missing in this thread, is that the real and sometime
tricky work is in key extraction and not the map/sort/map. there is no
easy way to describe how to extract multiple keys in the correct order
and then how to do the proper (ascending/descending, string/numeric)
comparisons on them. there are too many possibilities. i explored this
in depth as i designed the Sort::Records module. i had to invent a mini
language to describe all the possible key extractions and
comparisons. think along the lines of getopt::long but more powerful and
you can see the issues. try to describe how to extract this without
using perl code:

(split( ':', $rec-[2]{foo} ))[2]

and sort that numerically in descending order.

now add 2 more keys.

this would have to be a proper module and not a builtin op. there is no
reason to make this built in.

uri

-- 
Uri Guttman  -  [EMAIL PROTECTED]  --  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  ---  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  --  http://www.northernlight.com



Re: Schwartzian Transform

2001-03-22 Thread Dan Brian

 this would have to be a proper module and not a builtin op. there is no
 reason to make this built in.

This was essentially my point with regards to naming this op
"map_sort_map". Just explaining the function of the op negates its
usefulness *as* an op, because of the complexity of extracting the keys in
order, and the subsequent comparisons. Imagine the perldoc entry.




RE: Schwartzian Transform

2001-03-22 Thread Brent Dax


 "Brent" == Brent Dax [EMAIL PROTECTED] writes:

 Brent   @s = schwartzian(

 Please, if we're going to add an operator, let's not call it schwartzian!
 I have enough trouble already telling people how to spell my name. :)

Which is why my real suggestion was a 'tsort' ('tsort' eq 'transform and
sort') operator.  Someone else showed a very ugly syntax with an anonymous
hash, and I was out to prove there was a prettier way to do it.

BTW, I don't think 'schwartz' as the function name would be a good idea
either.  Then I'd have to write something silly like
schwartz {$a = $b} {s/foo/bar/} @ary; #I see your Schwartz is as big as
mine... --Dark Helmet

 Maybe I should have a kid named "Ian", so I can see on a roster some day:

 Schwartz,Ian

 :-)

:^)

--Brent Dax
[EMAIL PROTECTED]

This e-mail is a circumvention device as defined by the Digital Millennium
Copyright Act.

#qrpff
s''$/=\2048;while(){G=29;R=142;if((@a=unqT="C*",_)[20]48){D=89;_=unqb24,q
T,@
b=map{ord
qB8,unqb8,qT,_^$a[--D]}@INC;s/...$/1$/;Q=unqV,qb25,_;H=73;O=$b[4]9
|256|$b[3];Q=Q8^(P=(E=255)(Q12^Q4^Q/8^Q))17,O=O8^(E(F=(S=O147
^O)
^S*8^S6))9,_=(map{U=_%16orE^=R^=110(S=(unqT,"\xb\ntd\xbz\x14d")[_/16%8]
);E
^=(72,@z=(64,72,G^=12*(U-2?0:S17)),H^=_%64?12:0,@z)[_%8]}(16..271))[_]^((D
=8
)+=P+(~FE))for@a[128..$#a]}print+qT,@a}';s/[D-HO-U_]/\$$/g;s/q/pack+/g;eva
l




Re: Schwartzian Transform

2001-03-22 Thread John Porter

Brent Dax wrote:
 
 Someone else showed a very ugly syntax with an anonymous
 hash, and I was out to prove there was a prettier way to do it.

Do we want prettier?  Or do we want more useful?
Perl is not exactly known for its pretty syntax.


-- 
John Porter