Jump to content

Fractran: Difference between revisions

m
→‎{{header|Perl 6}}: Add referenced code to make a runnable block
m (→‎{{header|Perl 6}}: Add referenced code to make a runnable block)
Line 2,189:
'''Extra credit:'''
We can weed out all the powers of two into another infinite constant list based on the first list. In this case the sequence is limited only by our patience, and a ^C from the terminal. The <tt>.msb</tt> method finds the most significant bit of an integer, which conveniently is the base-2 log of the power-of-two in question.
<lang perl6>forsub fractran(@program) <17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11{
2, { first Int, map (* * $_).narrow, @program } ... 0
}
for fractran <17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11
15/14 15/2 55/1> {
say $++, "\t", .msb, "\t", $_ if 1 +< .msb == $_;
10,339

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.