Return to Snippet

Revision: 3263
at June 28, 2007 07:21 by dima767


Updated Code
static final popularityMap = [(0..9):'notPopular',(10..29):'notVeryPopular',(30..49):'popular',(50..100):'veryPopular',(101..Integer.MAX_VALUE):'ultraPopular']

tags = []
9.times { tags << 'tag1' }
12.times { tags << 'tag2' }
44.times { tags << 'tag3' }
50.times { tags << 'tag4' }
233.times { tags << 'tag5' }

tagsByPopularity = [:]
tags.sort().each { item ->
			if(!tagsByPopularity[item]) {
				count = tags.count(item)
		        	popularityMap.each { k,v ->
					if(k.contains(count))				
					tagsByPopularity[item] = v
				}
		}
}

println tagsByPopularity

Revision: 3262
at June 28, 2007 07:20 by dima767


Initial Code
static final popularityMap = [(0..9):'notPopular',(10..29):'notVeryPopular',(30..49):'popular',(50..100):'veryPopular',(101..Integer.MAX_VALUE):'ultraPopular']

tags = []
9.times { origList << 'tag1' }
12.times { origList << 'tag2' }
44.times { origList << 'tag3' }
50.times { origList << 'tag4' }
233.times { origList << 'tag5' }

tagsByPopularity = [:]
tags.sort().each { item ->
			if(!tagsByPopularity[item]) {
				count = tags.count(item)
		        	popularityMap.each { k,v ->
					if(k.contains(count))				
					tagsByPopularity[item] = v
				}
		}
}

println tagsByPopularity

Initial URL

                                

Initial Description

                                

Initial Title
Simple tag cloud

Initial Tags
groovy

Initial Language
Groovy