develooper Front page | perl.perl6.language | Postings from April 2005

junction adverb: :except

Thread Next
David Christensen
April 18, 2005 16:01
junction adverb: :except
Message ID:
Hypothetical here:

If we want to calculate a set of values for a junction which map nicely 
to a range with a few outliers, would it be possibly to have a 
qualifier :except which allows us to make exceptions to our given 
range?  I.e.,

(Ignore for the moment the inefficiency of the choice of this 
particular algorithm.)

my $year = 1900;  # or whatever

my $leap_year = $year % 400 == any(0..400 :by(4) :except(100,200,300));

Here except would be a modifier on the range being generated for any(). 
  I could also see except being used to "strip choices" from junctions:

my $j = 1|2|3|4;
my $k=$j :except(2);  # 1|3|4

Let me know if I'm totally abusing junctions here...


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About