summaryrefslogtreecommitdiff
path: root/perl9.buetow.org/content/New-Features.sub/New-Contexes.xml
blob: 823096290077bd0e3591d99254117778482bb82e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
<content>
  <pagetitle>Perl 9 contians new datatypes/contexes!</pagetitle>
  <text>Perl now got some new data types and contexes:</text>
  <textheader>Fuzzy Context ~</textheader>
  <text>Everything is not sharp but fuzzy! Fuzzy does always something like the desired value! It is never exact!</text>
  <code>
my ~fuz; # Fuzzy type 


use PHP qw(Function::echo);

# You don't know if its assigning list or scalar context!
my ~fuzzy = qw(Hello mister Edd); 
echo&lt;-~fuzzy; // Can print 'Hello' or can print '3' 

my ~foo = 'Good morning';
echo&lt;-~foo; # Due a built in AI engine, this may print 'Good morning' or 'Bad afternoon'
  </code>
  <textheader>Matrix Context []</textheader>
  <text>No more limitations to list and scalar and void contexes!</text>
  <code>
my ([]matrix1,[]matrix2) = (
	((1, 0, 0), (0, 1, 0), (0, 0, 1)),
	((0, 1, 0), (0, 0, 1), (1, 0, 0)),
); 

[]matrix1 += []matrix2; # Will add matrix2 to matrix1!

[]matrix1.say; # Will print ((1, 1, 0), (0, 1, 1), (1, 0, 1))
  </code>
  <text>If you want to do multi dimensional matrices then you can do:</text>
  <code>
my [][]matrix = 
	(((1, 0, 0), (0, 1, 0), (0, 0, 1)),
	 ((0, 1, 0), (0, 0, 1), (1, 0, 0)),
	 ((0, 1, 0), (0, 0, 1), (1, 0, 0)));
  </code>
  <text>etc...</text>
</content>