mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* Drop duplicated sample code * Drop another style sample https://github.com/ruby/ruby/pull/2389#issuecomment-522489520 * Update sample list
		
			
				
	
	
		
			12 lines
		
	
	
	
		
			226 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			12 lines
		
	
	
	
		
			226 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
# word occurrence listing
 | 
						|
# usage: ruby occur.rb file..
 | 
						|
freq = Hash.new(0)
 | 
						|
while line = gets()
 | 
						|
  line.scan(/\w+/) do |word|
 | 
						|
    freq[word] += 1
 | 
						|
  end
 | 
						|
end
 | 
						|
 | 
						|
for word in freq.keys.sort!
 | 
						|
  print word, " -- ", freq[word], "\n"
 | 
						|
end
 |