in reply to Testing the Uniformity of an Array by its Elements

Lots of ways to do this, here's one using Perl6::Junction:
use Perl6::Junction qw(all); print "uniform\n" if (all(@array) eq $array[0]);

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan

Replies are listed 'Best First'.
Re^2: Testing the Uniformity of an Array by its Elements
by neversaint (Deacon) on Nov 02, 2005 at 14:35 UTC
    Dear tirwhan,

    Thanks for the response. This module (Perl6::Junction) surely is interesting, glad you brought it up.
    But is it safe for a production code?

    ---
    neversaint and everlastingly indebted.......

      That would depend on your definition of "production safe" I guess. Some pointers

      • It has a fairly extensive test suite, which currently passes on all platforms
      • The implementation is straightforward and does not rely on any 'dark magic' sort of code(Update:Well, it does use overload which some people consider dark and dangerous magic, but I disagree with these people ;-)
      • There are no open bug reports on CPAN (nor are there resolved ones)
      • It is at version 1.10 (which depending on the author's philosophy may signify something)
      • It is not a source filter (some Perl6:: modules are not considered production safe because they are implemented as source filters)

      Personally I've never had a problem with it. While I've not yet used it in client code, I would do so (with tests for all expected outcomes of my own code, as always). If you want more assurance you could always mail the module author and see what he thinks.


      Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan