Algorithm-QuineMcCluskey

 view release on metacpan or  search on metacpan

lib/Algorithm/QuineMcCluskey/Format.pm  view on Meta::CPAN


=head3 arrayarray()

Returns a more compact string form of the covers structure.

=cut

sub arrayarray
{
	my ($ar) = @_;
	my $fmt = "%" . length(scalar @{$ar}) . "d: [%s]";
	my $idx = 0;
	my @output;

	for my $ref (@{$ar})
	{
		push @output, sprintf($fmt, $idx, (defined $ref)? join(", ", @{ $ref }): " ");
		$idx++;
	}

	return "\n" . join("\n", @output);

lib/Algorithm/QuineMcCluskey/Util.pm  view on Meta::CPAN


=cut

sub hammingd1pos
{
	#
	# Xor the strings. The result will be a string in the
	# non-printing range (in fact equal characters will result
	# in a null character), so to each character Or a '0'.
	#
	my $v = ($_[0] ^ $_[1]) | (qq(\x30) x length $_[0]);

	#
	# Strings that don't have a Hamming distance of one are of no
	# interest. Otherwise, return that character position.
	#
	return -1 unless(scalar(() = $v=~ m/[^0]/g) == 1);

	$v =~ m/[^0]/g;
	return pos($v) - 1;
}



( run in 0.325 second using v1.01-cache-2.11-cpan-65fba6d93b7 )