Range consolidation: Difference between revisions

m
→‎{{header|Raku}}: .perl -> .raku
m (→‎{{header|Raku}}: .perl -> .raku)
Line 1,408:
=={{header|Raku}}==
(formerly Perl 6)
{{works with|Rakudo|20182020.1208.1}}
In Raku, a Range is a first class object with its own specialized notation. Raku Ranges allow for exclusion of the boundary numbers. This example doesn't since it isn't a requirement in this task. Much of the logic is lifted from the [[Set_of_real_numbers#Raku|Set_of_real_numbers]] task with simplified logic for the much simpler requirements.
 
Line 1,437:
[[1, 3], [-6, -1], [-4, -5], [8, 2], [-6, -6]]
-> @intervals {
printf "%46s => ", @intervals.perlraku;
say reverse consolidate |@intervals.grep(*.elems)».sort.sort({ [.[0], .[*-1]] }).map: { Range.new(.[0], .[*-1]) }
}</lang>
2,392

edits