\n#! /usr/bin/ruby\nclass RangeBucket\n \n def initialize (min, max)\n @min = min;\n @max = max;\n @count = 0;\n end\n\n def add_if_in (element)\n if @min < element && element < @max\n @count += 1;\n end\n end\n\n def to_s ()\n sprintf("%1.5f - %1.5f: %d", @min, @max, @count);\n end\n \nend\n\nranges = [\n RangeBucket.new(0, 0.1),\n RangeBucket.new(0.1, 0.4),\n RangeBucket.new(0.4, 0.8),\n RangeBucket.new(0.8, 1),\n];\n\n1000.times{\n value = rand();\n ranges.each {|range| range.add_if_in(value)};\n}\n\nputs ranges;\n
That should be translatable into any language that you want, including Smalltalk. (Ruby chosen because I know it and its object model is similar to Smalltalk.)