*** Demonstration of the Flip-Flop Operators *** __A______B____X___ __A______B____X___ 0* .. 0 = 0* ... 0 = 0* .. 1 = 0* ... 1 = 0* .. 0 = 0* ... 0 = 1* .. 0* = 1 1* ... 0 = 1 0 .. 0* = 2 0 ... 0* = 2 0 .. 0* = 3 0 ... 0* = 3 0 .. 1* = 4E0 0 ... 1* = 4E0 0* .. 0 = 0* ... 0 = 0* .. 0 = 0* ... 0 = 1* .. 1* = 1E0 1* ... 1 = 1 0* .. 0 = 0 ... 0* = 2 0* .. 0 = 0 ... 0* = 3 1* .. 0* = 1 1 ... 0* = 4 0 .. 0* = 2 0 ... 0* = 5 0 .. 1* = 3E0 0 ... 1* = 6E0 0* .. 1 = 0* ... 1 = 1* .. 1* = 1E0 1* ... 1 = 1 1* .. 0* = 1 1 ... 0* = 2 0 .. 0* = 2 0 ... 0* = 3 0 .. 1* = 3E0 0 ... 1* = 4E0 0* .. 0 = 0* ... 0 = 1* .. 1* = 1E0 1* ... 1 = 1 1* .. 1* = 1E0 1 ... 1* = 2E0 1* .. 1* = 1E0 1* ... 1 = 1 0* .. 0 = 0 ... 0* = 2 0* .. 1 = 0 ... 1* = 3E0 0* .. 0 = 0* ... 0 = (* = Evaluated) ##```## #!/usr/bin/env perl use warnings; use strict; print "*** Demonstration of the Flip-Flop Operators ***\n\n"; my @tests = qw/ 0:0 0:1 0:0 1:0 0:0 0:0 0:1 0:0 0:0 1:1 0:0 0:0 1:0 0:0 0:1 0:1 1:1 1:0 0:0 0:1 0:0 1:1 1:1 1:1 0:0 0:1 0:0 /; print join(' ', ("__A______B____X___") x 2), "\n"; sub fmt { my (\$lv,\$le,\$op,\$rv,\$re,\$v) = @_; return sprintf ' %s%s %-3s %s%s = %-3s ', \$lv, \$le?'*':' ', \$op, \$rv, \$re?'*':' ', \$v; } for (@tests) { my (\$lv, \$rv) = split /:/; my (\$le, \$re); my \$lf = sub { \$le=1; \$lv }; my \$rf = sub { \$re=1; \$rv }; (\$le, \$re) = (0,0); my \$v1 = &\$lf .. &\$rf; print fmt(\$lv,\$le,'..' ,\$rv,\$re,\$v1); print ' '; (\$le, \$re) = (0,0); my \$v2 = &\$lf ... &\$rf; print fmt(\$lv,\$le,'...',\$rv,\$re,\$v2); print "\n"; } print "\n(* = Evaluated)\n"; ```