#!/usr/bin/perl -s use v5.16; use Test2::V0 '!float'; use PDL; use Math::Prime::Util qw(fromdigits todigits); our ($tests, $examples); run_tests() if $tests || $examples; # does not return die <slice('-1:0'); } ### Examples and tests sub run_tests { SKIP: { skip "examples" unless $examples; is bin_pal(5), T(), 'example 1'; is bin_pal(4), F(), 'example 2'; } SKIP: { skip "tests" unless $tests; my @head = '1'; push @head, int rand 2 for 0 .. 2047; my $n = fromdigits([@head, reverse @head], 2); is bin_pal($n), T(), 'random 4096 bit binary palindrome'; is bin_pal($n - 1), F(), 'one off random binary palindrome'; } done_testing; exit; }