Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks
if you build an array, say with the following snippet:
What I want to do is to calculate the Levenshtein distance between each element and all the rest in the array.
If I have only 2 IDS, it is easy:
What must I write in order to sequentially grep each of the IDS and then compare it to the rest? With slice I guess I would remove it and I do not want that, maybe slice and push once I am done? Something smarter?
if you build an array, say with the following snippet:
$file=$ARGV[0]; @all_IDS=(); open IN, $file; while(<IN>) { chomp $_; push @all_IDs, $_; } close IN;
What I want to do is to calculate the Levenshtein distance between each element and all the rest in the array.
If I have only 2 IDS, it is easy:
use Text::Levenshtein qw(distance); $distance = distance ($id1, $id2);
What must I write in order to sequentially grep each of the IDS and then compare it to the rest? With slice I guess I would remove it and I do not want that, maybe slice and push once I am done? Something smarter?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Compare each array element to the rest, sequentially
by Dallaylaen (Chaplain) on Dec 07, 2017 at 15:32 UTC | |
Re: Compare each array element to the rest, sequentially
by Laurent_R (Canon) on Dec 07, 2017 at 23:11 UTC | |
by NetWallah (Canon) on Dec 08, 2017 at 02:33 UTC | |
by Laurent_R (Canon) on Dec 08, 2017 at 08:52 UTC | |
Re: Compare each array element to the rest, sequentially
by thanos1983 (Parson) on Dec 07, 2017 at 18:16 UTC | |
Re: Compare each array element to the rest, sequentially
by Anonymous Monk on Dec 07, 2017 at 15:17 UTC | |
by poj (Abbot) on Dec 07, 2017 at 16:27 UTC |
Back to
Seekers of Perl Wisdom