That doesn't solve the general problem:

  my $junc = any -4 .. Inf;
  my @domain = -Inf .. 4;

  my @values = @domain |==| $junc;
  say @values.perl
  >>> [ -4 .. 4 ]

How do you code that using "grep"?



________________________________
From: Daniel Ruoso <dan...@ruoso.com>
To: Dave Whipp <d...@dave.whipp.name>
Cc: perl6-language@perl.org
Sent: Monday, January 5, 2009 11:24:29 AM
Subject: Re: rfc: The values of a junction

Em Seg, 2009-01-05 às 07:57 -0800, Dave Whipp escreveu:
>    my $ace = 1 | 11;
>    my $seven = 7;
>    my @hand = $ace xx 3, $seven;
>    my $junc_value = [+] @hand;  ## any( 10, 20, 30, 40 )
> There are a bunch of possible values in the junction. The one we care 
> about is the largest that is not greater than 21. Using Perl6 as it 
> stands today, the way to extract this value is brute force:
>    my $concrete_value = max (0..21).grep: { $^score == $junc_value };

Well, that considering we don't have any introspection into junctions,
but I think it should be quite straight-forward to make junctions behave
as a list of its members...

  my $ace = 1 | 11;
  my $seven = 7;
  my @hand = $ace xx 3, $seven;
  my $junc_value = [+] @hand;
  my $concrete_value = max $junc_value.grep: { $^scope < 21 }; 

daniel

Reply via email to