Fractran: Difference between revisions
Content deleted Content added
→{{header|Perl 6}}: minor simplification |
|||
Line 1,681: | Line 1,681: | ||
A Fractran program potentially returns an infinite list, and infinite lists are a common data structure in Perl 6. The limit is therefore enforced only by slicing the infinite list. |
A Fractran program potentially returns an infinite list, and infinite lists are a common data structure in Perl 6. The limit is therefore enforced only by slicing the infinite list. |
||
<lang perl6>sub fractran(@program) { |
<lang perl6>sub fractran(@program) { |
||
2, { first Int, map (* * $_).narrow, |
2, { +first Int, map (* * $_).narrow, @program } ... 0 |
||
} |
} |
||
say fractran(<17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 |
say fractran(<17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 |