in reply to Re^6: list of unique strings, also eliminating matching substrings
in thread list of unique strings, also eliminating matching substrings
That looks like you do not have Inline::C installed correctly, but I can't help you with that. If it is the case...ie. if the Inline::C installation tests are failing, then you shoudl post a new thread about that to get help.
In the interim, you can try this pure perl version which is only half as fast as the inline version, but that should still be 7 times faster than your current solution. Let me know how you get on.
#! perl -slw use strict; use Time::HiRes qw[ time ]; $|++; sub uniq{ my %x; @x{@_} = (); keys %x } my $start = time; my @uniq = uniq <>; chomp @uniq; @uniq = sort{ length $a <=> length $b } @uniq; my $all = join chr(0), @uniq; my $p = 0; for my $x ( @uniq ) { $p += 1+ length $x; next if 1+ index $all, $x, $p; ## COrrected per LanX below. print $x; } printf STDERR "Took %.3f\n", time() - $start;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: list of unique strings, also eliminating matching substrings
by LanX (Saint) on Jun 02, 2011 at 15:05 UTC | |
by BrowserUk (Patriarch) on Jun 03, 2011 at 05:37 UTC | |
by LanX (Saint) on Jun 03, 2011 at 11:52 UTC | |
by BrowserUk (Patriarch) on Jun 03, 2011 at 14:38 UTC | |
by LanX (Saint) on Jun 03, 2011 at 15:02 UTC | |
| |
|
Re^8: list of unique strings, also eliminating matching substrings
by LanX (Saint) on Jun 02, 2011 at 16:02 UTC | |
by BrowserUk (Patriarch) on Jun 02, 2011 at 16:22 UTC |