Script started on Mon Oct 09 11:26:15 2000 <33 nova:~/web/perl > cat CrossProd.cgi print "\n{ "; for ($i = 1; $i <= 8; $i++) { for ($j = 1; $j <= 8; $j++) { if ($i == 8 && $j == 8) { print "($i,$j) "; } else { print "($i,$j), " } } if ($i < 8) { print "\n "; } else { print " }\n\n"; } } <34 nova:~/web/perl > perl CrossProd.cgi { (1,1), (1,2), (1,3), (1,4), (1,5), (1,6), (1,7), (1,8), (2,1), (2,2), (2,3), (2,4), (2,5), (2,6), (2,7), (2,8), (3,1), (3,2), (3,3), (3,4), (3,5), (3,6), (3,7), (3,8), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6), (4,7), (4,8), (5,1), (5,2), (5,3), (5,4), (5,5), (5,6), (5,7), (5,8), (6,1), (6,2), (6,3), (6,4), (6,5), (6,6), (6,7), (6,8), (7,1), (7,2), (7,3), (7,4), (7,5), (7,6), (7,7), (7,8), (8,1), (8,2), (8,3), (8,4), (8,5), (8,6), (8,7), (8,8) } <36 nova:~/web/perl > cat SubSet1.cgi # This PERL program demonstrates the Cartesian Products and subsets # of A cross A where # A = { 1, 2, 3, 4, 5, 6, 7, 8 } # After the IF statement below is described, you should be able to # describe the subset using the example handouts and textbook # notation. print "\n\n{ "; for ($i = 1; $i <= 8; $i++) { for ($j = 1; $j <= 8; $j++) { if ($i + $j == 8 || $i * $j == 16 || $i * $j == 32) { print "($i,$j) "; } } } print "}\n\n"; # Suppose the above if ( ) statement were modified as follows: # if ($i + $j == 5 || $i * $j == 8 || $i * $j == 64) # Enumerate the members of the set that would be printed out. <37 nova:~/web/perl > perl SubSet1.cgi { (1,7) (2,6) (2,8) (3,5) (4,4) (4,8) (5,3) (6,2) (7,1) (8,2) (8,4) } <38 nova:~/web/perl > ^Dexit script done on Mon Oct 09 11:27:13 2000