# New Ticket Created by Richard Hainsworth
# Please include the string: [perl #63918]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=63918 >
An .eigenstates method is needed for Object.
Background:
The following code may or may not fail depending on whether the junction
is 'picked':
my @s = 1|11,2,3,4,5,6,7; # the 1|11 junction as in the value of an ace
in 21
my @x;
loop {
@x = @s.pick(3);
([+] @x).eigenstates.min.say;
};
Jon Lang wrote:
... in the same way that an item can be treated as a
one-item list for the purposes of list context (and vice versa), a
non-Junction should be able to be treated as a Junction with a single
eigenstate (i.e., a Singleton) for the purposes of junctive semantics.
That is, $x.^eigenstates === ($x) if $x is not a junction. Not only
does this reduce the need to test for junctions, but it also makes
that test fairly straightforward: count the eigenstates. If you only
have one, it isn't a junction.
On Sun, Mar 15, 2009 at 07:26:00PM +0100, Jonathan Worthington wrote:
> > You can detect junctions by smart-matching against the Junction type
> > (e.g. $sum ~~ Junction).
> >
> > my @s=1|11,2,3,4,5,6;
> > loop {
> > my $sum = [+] @s.pick(3);
> > say $sum ~~ Junction ?? $sum.eigenstates.min !! $sum;
> > }
>
Larry Wall wrote:
I see no particular reason not to add an .eigenstates method to Object
that returns a list of the object itself . It doesn't interfere with
the .eigenstates method defined in Junction, unless you want to
determine whether something is a Junction by seeing if it can respond
to .eigenstates, which seems wrongish.
Larry