On 28.06.2007 12:56, Robert Dober wrote:
> On 6/28/07, Robert Klemme <shortcutter / googlemail.com> wrote:
> 
>> Btw, thanks for leaving the inject solution to me. :-)
> Shame on you!!! ;)

Um, why?  Somehow I don't get the joke, sorry. :-)

> But that is not what OP asked for <G>
> 
> (a|[]).map{|e|a.grep(e).size} ### I know it might not work as we use 
> #=== here

Sorry, Robert, but I don't think this is what the OP was asking for:

irb(main):001:0> a = %w{a a a b b c c c d d e}
=> ["a", "a", "a", "b", "b", "c", "c", "c", "d", "d", "e"]
irb(main):002:0> a.map{|e|a.grep(e).size}
=> [3, 3, 3, 2, 2, 3, 3, 3, 2, 2, 1]

Your solution repeats counts for the same string but as far as I can see 
from his original posting he wants counts for each string just once.

> More generally we have therefore
> 
> (a|[]).map{|e|a.select{|x|x==e}.size}
> 
> Maybe OP preferred
> ..).sort.map{...
> 
> and sorry OP, I just needed this working break.

:-)

Kind regards

	robert