develooper Front page | perl.perl6.language | Postings from March 2009

a junction or not

Thread Next
From:
Richard Hainsworth
Date:
March 15, 2009 11:19
Subject:
a junction or not
Message ID:
49BD46A2.1090404@rusrating.ru
The following (the n:> is to mark the lines) are legal:

1:> my @x = 1,2,3,4; ([+] @x).say; # output 10
2:> my @x = 1|11,2,3,4; ([+] @a).perl.say; # output any(10,20)
3:> my @x = 1|11,2,3,4; ([+] @a).eigenstates.min.say; # output 10

However, the next line isnt
4:> my @x = 1,2,3,4; ([+] @a).eigenstates.min.say; # Method 
'eigenstates' not found for invocant of class 'Integer'

But suppose I dont know until runtime whether @x contains a junction or 
not, eg.,

my @s = 1|11,2,3,4,5,6,7; # as in the value of an ace in 21
my @x;
loop {
    @x = @s.pick(3);
    ([+] @x).eigenstates.min.say;
};

Eg.
$ perl6
 > my @s=1|11,2,3,4,5,6;my @x; loop {@x=@s.pick(3);([+] 
@x).eigenstates.min.say}
8
6
Method 'eigenstates' not found for invocant of class 'Integer'
 >

I suggested to Masak on irc that an integer is a singleton, hence a 
degenerate Junction. He said not.

So, how to determine whether a junction is being used or not?

Richard

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About