Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Understanding the Schwartzian transform.

by tobyink (Abbot)
on Jul 22, 2013 at 07:51 UTC ( #1045610=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @sorted =
       map  { $_->[0] }
       sort { $a->[1] cmp $b->[1] } # or <=>, or $b before $a
       map  { [$_, f($_)] }
       @unsorted;
    
  2. or download this
    # the first map does this
    qw(8 11 9 4 3) --> (
    ...
      [ 4, "vi"],
      [ 3, "iii"],
    )
    
  3. or download this
    # the sort does this:
    (
    ...
      [ 8, "viii"],
      [11, "xi"],
    )
    
  4. or download this
    (
      [ 3, "iii"],
    ...
      [ 8, "viii"],
      [11, "xi"],
    ) --> qw( 3 9 4 8 11 )
    
  5. or download this
    use strict;
    use warnings;
    ...
    
    __END__ # output shown below
    3 4 9 8 11
    
  6. or download this
    my @sorted = sort { f($a) cmp f($b) } @unsorted;
    
  7. or download this
    *f = sub {
        $::count++;
        END { print "f() called $::count times\n" };
        goto \&Roman::roman;
    };
    
  8. or download this
    use List::Util "shuffle";
    my @unsorted = shuffle(1..100);
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1045610]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2014-07-28 10:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (195 votes), past polls