help would be appreciated to help me understand what to pass to the "diff" or "traverse_sequences" to allow me to compare 4.1 and 4.0 and call them equal.

i have attempted to pass in both a named and an anonymous subroutine that attempts to access via symbolic reference the variables $a and $b of the scope calling "&$keyGen" in "_longestCommonSubsequence" which really calls my subroutine.

if i understand the camel book correctly, symbolic references do not work across packages. (just read that). hmphh!

in my sub i check if they are close; if so, take the avg and pump through sprintf. return either the original first parameter or the new avg.

then both calls to "&$keyGen" would be returning the same value.

much thanks, jim

sample code trying out my idea leaving in various attempts.

use warnings; use strict; use lib qw( /rshome/jaw2/lib/site_perl/5.8.0 ); use Algorithm::Diff qw( diff ); my @a = qw( 1.0 2.1 3.2 4.0 4.9 5.8 ); my @b = qw( 1.0 2.0 3.0 4.0 5.0 6.0 ); my @d = diff( \@a, \@b, sub { my( $o ) = @_; #my( $o, $aa, $bb ) = @_; #no strict 'refs'; my $d = abs( $a - $b ); #my $d = abs( $$aa - $$bb ); if( $d <= 0.1 ) { my $avg = sprintf "%14.6e", ( $a + $b ) / 2; #my $avg = sprintf "%14.6e", ( $$aa + $$bb ) / + 2; return $avg; } return $o; } ); #####'a', 'b' #my @d = diff( \@a, \@b, \&mykeygen, 'a', 'b' ); #my @d = diff( \@a, \@b, \&mykeygen, { 'a' => '$_[0]', 'b' => '$_[1]' +} ); #my @d = diff( \@a, \@b, \&mykeygen, '$_[0]', '$_[1]' ); print "d array:\n", join( "\n\t", @d ), "\n";

In reply to using Algorithm::Diff for floats by jim_neophyte

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.