Created
March 20, 2014 18:39
-
-
Save grondilu/9670877 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Automaton { | |
my sub B($x) { 1 +< $x } | |
has uint $.rule; | |
has uint64 $.state; | |
method gist { $!state.fmt("%064b").flip } | |
method succ { | |
loop (my uint64 $st = my $i = 0; $i < 64; $i++) { | |
if ($!rule +& B(7 +& (($!state +> ($i - 1)) +| ($!state +< (65 - $i))))) { | |
$st = $st +| B($i); | |
} | |
} | |
self.new: :$!rule, :state($st); | |
} | |
} | |
my Automaton $a .= new: :rule(90), :state( 1 ); | |
say $a++ for ^10; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment