#!/usr/bin/env perl

use 5.022;
use strict;
use warnings;
use Math::DifferenceSet::Planar;

$| = 1;

die "usage: pds_eta [file]...\n" if @ARGV && $ARGV[0] =~ /^-[^-]/s;

my $delta = shift @ARGV;

while (<<>>) {
    s/^\s+//;
    my @e = split /\s+/;
    next if !@e;

    die "integer numbers separated by whitespace expected\n"
        if grep { !/^(?:0|[1-9][0-9]*)\z/ } @e;

    my $s = Math::DifferenceSet::Planar->from_elements(@e);

    my $eta = $s->eta;

    print "$eta\n";
}

__END__
=head1 NAME

pds_eta - display eta values of planar difference sets

=head1 SYNOPSIS

  pds_eta [file]...

=head1 DESCRIPTION

This example program reads planar difference sets, one per line,
as integer numbers separated by whitespace, calculates the eta
value of each set, and writes these values to standard output.
Cf. L<Math::DifferenceSet::Planar> for the definition of I<eta>.

The program will fail with an error message if an input line is not a
planar difference set.

=head1 AUTHOR

Martin Becker, E<lt>becker-cpan-mp I<at> cozap.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (c) 2021 by Martin Becker, Blaubeuren.

This library is free software; you can distribute it and/or modify it
under the terms of the Artistic License 2.0 (see the LICENSE file).

=head1 DISCLAIMER OF WARRANTY

This library is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.

=cut
