• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: getting duplicates in a list by item id
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: getting duplicates in a list by item id
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Re: getting duplicates in a list by item id (From: "Nigel Garvey" <email@hidden>)

  • Prev by Date: Re: Reading and writing records
  • Next by Date: Re: getting duplicates in a list by item id
  • Previous by thread: Re: getting duplicates in a list by item id
  • Next by thread: Re: getting duplicates in a list by item id
  • Index(es):
    • Date
    • Thread