Pathologically Eclectic Rubbish Lister PerlMonks

by thechartist (Monk)
 on Dec 29, 2017 at 04:57 UTC Need Help??

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

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?