Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

thechartist's scratchpad

by thechartist (Monk)
on Dec 29, 2017 at 04:57 UTC ( #1206392=scratchpad: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $foo = 99; # Assigns the integer 99 to $foo.  Scalar context.
    @Foo = ('Jack', 5, 'Jill', 4, 'John', 7); # A list assigned to @foo, v
    +alues separated by commas.
    %foo = ('Jack', 5, 'Jill', 4, 'John', 7); # A list as key, value pairs
    +. Better ways to write this exist.
    
  2. or download this
    $ perl -MPDL -e "print PDL::VERSION;"
    
  3. or download this
    $ perl -MPDL -e "$arr = sequence(10); print $arr;"
    
  4. or download this
    $ perl -MPDL -e "$arr = ones(3,3), print $arr;"
    
  5. or download this
    $ perl -MPDL -e "$arr = sequence(10); $odd = where($arr, ($arr%2) == 1
    +); print $odd;"
    
  6. or download this
    Input:  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    Output: [ 0, -1,  2, -1,  4, -1,  6, -1,  8, -1]
    
  7. or download this
     perl -MPDL -e "$arr = sequence(10); $odd = $arr->where($arr % 2 == 1); $odd .= -1 ; print $arr;"
  8. or download this
    Input:  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] [ 0, -1,  2, -1,  4, -1,  6, -1
    +,  8, -1]
    
  9. or download this
    $ perl -MPDL -e "$arr = sequence(10); $out = sequence(10); $odd = $arr->where($arr %2 == 1); $odd .= -1; print $out, $arr;"
  10. or download this
    Input: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    Output: [ [0, 1, 2, 3, 4],
              [5, 6, 7, 8, 9] ]
    
  11. or download this
    $ perl -MPDL -e "$seq = sequence(10); $seq_1 = $seq->reshape(5,2); pri
    +nt $seq_1;"
    
  12. or download this
    Input: a = [0,1,2,3,4,5,6,7,8,9]
           b = [1,1,1,1,1,1,1,1,1,1]
    ...
             [5, 6, 7, 8, 9],
             [1, 1, 1, 1, 1],
             [1, 1, 1, 1, 1]]
    
  13. or download this
    $ perl -MPDL -e "$arr_a = sequence(10), $arr_b = ones(10); $out = pdl(
    + $arr_a, $arr_b )->reshape( 5,4 ) ; print $out; "
    
  14. or download this
    Output: [[0, 1, 2, 3, 4, 1, 1, 1, 1, 1],
             [5, 6, 7, 8, 9, 1, 1, 1, 1, 1]]
    
  15. or download this
    perl -MPDL -e "$arr_a = sequence(10)->reshape(5,2); $arr_b = ones(10)-
    +>reshape(5,2); print append( $arr_a, $arr_b );"
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2022-12-05 21:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?