------art_167500_26946097.1178884222482
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Assuming my previous assumption of what exactly is needed... at this point
it's academic anyway, right :>

This will produce the same result with much cleaner code than my previous
post:


APPENDAGE_START  _"

def make_items_unique(list)
  hsh  ash.new { |h,k| h[k]  }
  list_mod  ist.collect do |x|
    hsh[x] + 
    x.to_s + APPENDAGE_START + hsh[x].to_s
  end
end

list1  w{one one two three four four five}
list2  w{one three three four five five five}

puts "before --- list1:#{list1}"
puts "before --- list2:#{list2}"

list1_mod  ake_items_unique(list1)
list2_mod  ake_items_unique(list2)

list3  ist1_mod - list2_mod
list4  ist2_mod - list1_mod

list1  ist3.collect { |x| x.split(APPENDAGE_START)[0] }
list2  ist4.collect { |x| x.split(APPENDAGE_START)[0] }

puts "after --- list1:#{list1}"
puts "after --- list2:#{list2}"

---------------
outputbefore --- list1:oneonetwothreefourfourfive
before --- list2:onethreethreefourfivefivefive
after --- list1:onetwofour
after --- list2:threefivefive


On 5/11/07, Enrique Comba Riepenhausen <ecomba / mac.com> wrote:
>
>
> On 11 May 2007, at 10:23, Brian Candler wrote:
>
> > On Fri, May 11, 2007 at 04:55:14PM +0900, Enrique Comba
> > Riepenhausen wrote:
> >> Do you want to remove the elements that are in the same position on
> >> the lists and are equal?
> >>
> >> If so I would say:
> >>
> >> require 'generator'
> >>
> >> list1  1,1,2,3,4,6] # I included the 6 to show what I mean...
> >> list2  2,2,3,5,5,6] # I included the 6 to show what I mean...
> >>
> >> def RemoveDupsFromLists ( list1 , list2 )
> >>   lists  yncEnumerator.new(list1, list2)
> >>   lists.each { |element_list1, element_list2|
> >>
> >>     if list1[element_list1] list2[element_list2]
> >>       list1.delete(element_list1)
> >>       list2.delete(element_list2)
> >>     end
> >>   }
> >> end
> >
> > Is it safe to delete from lists while you're enumerating through them?
>
> Actually not ;) It depends if other objects are trying to access
> those lists at the same time though...
>
>
>

------art_167500_26946097.1178884222482--