- 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.
- or download this
$ perl -MPDL -e "print PDL::VERSION;"
- or download this
$ perl -MPDL -e "$arr = sequence(10); print $arr;"
- or download this
$ perl -MPDL -e "$arr = ones(3,3), print $arr;"
- or download this
$ perl -MPDL -e "$arr = sequence(10); $odd = where($arr, ($arr%2) == 1
+); print $odd;"
- 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]
- or download this
perl -MPDL -e "$arr = sequence(10); $odd = $arr->where($arr % 2 == 1); $odd .= -1 ; print $arr;" - 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]
- or download this
$ perl -MPDL -e "$arr = sequence(10); $out = sequence(10); $odd = $arr->where($arr %2 == 1); $odd .= -1; print $out, $arr;" - 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] ]
- or download this
$ perl -MPDL -e "$seq = sequence(10); $seq_1 = $seq->reshape(5,2); pri
+nt $seq_1;"
- 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]]
- 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; "
- or download this
Output: [[0, 1, 2, 3, 4, 1, 1, 1, 1, 1],
[5, 6, 7, 8, 9, 1, 1, 1, 1, 1]]
- 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 );"