Re: getting duplicates in a list by item id
Re: getting duplicates in a list by item id
- Subject: Re: getting duplicates in a list by item id
- From: "Mark J. Reed" <email@hidden>
- Date: Sun, 26 Aug 2007 11:24:54 -0400
On 8/26/07, Nigel Garvey <email@hidden> wrote:
> I've seen a lot of talk in this thread about associative arrays, Ruby,
> and Perl, and how mind-bogglingly fast they are, but no actual code. Did
> that particualr post not make it to the digest?
Here's the complete Ruby program. It assumes the POSIX paths are in a
text file named 'paths.txt', one per line, with no other fields, but
is easily modified to deal with other sources of data and formats:
pathList = File.readlines('paths.txt')
pathPositions = {}
pathList.each_with_index do |path, position|
path.chomp!
(pathPositions[path] ||= []).push(position)
end
pathPositions.each do |path, positions|
puts "#{path} - #{positions.join(',')}"
end
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden