|
|
Subject:
perl script: Creating a set of sets of intergers
Category: Computers > Programming Asked by: skg-ga List Price: $5.00 |
Posted:
04 Jul 2004 15:43 PDT
Expires: 13 Jul 2004 03:30 PDT Question ID: 369648 |
|
There is no answer at this time. |
|
Subject:
Re: perl script: Creating a set of sets of intergers
From: hailstorm-ga on 04 Jul 2004 19:14 PDT |
If the duplicates are in your data file, you could just pipe the data file through a program such as uniq to filter out all of the duplicates before processing. |
Subject:
Re: perl script: Creating a set of sets of intergers
From: hailstorm-ga on 04 Jul 2004 19:16 PDT |
Of course, the functionality of uniq can be implemented fairly simply in Perl itself: perl -ne 'print unless $s eq $_; $s = $_' |
Subject:
Re: perl script: Creating a set of sets of intergers
From: skg-ga on 04 Jul 2004 23:37 PDT |
The data could occur at an intermediate step of the program. I posed the problem this way for simplicity. To rephrase the problem: Given a data structure, D that stores family of sets and a query set nset. Check if nset is already present in D. Ofcourse i can go through each set in D and compare it with nset. But i want to do this more efficently. This is how i would have done in C++. Create a function comparison(Set a, Set b) that provides <=> over sets and then use stl::map with this comparison. |
Subject:
Re: perl script: Creating a set of sets of intergers
From: skg-ga on 13 Jul 2004 03:30 PDT |
One cheap solution is to use Hash of arrays: $str = join(":", @arr); $HOA{$str} = 1; To recover: @arr = split(/:/, $str); |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |