#!/usr/bin/env ruby def generate( base, interval ) lambda { base += interval } end # create incrementor generator first_inc = generate( 5, 2 ) # generate first incrementor puts first_inc.call # output: 7 puts first_inc.call # output: 9 second_inc = generate( 3, 1 ) # generate second incrementor puts second_inc.call # output: 4 puts second_inc.call # output: 5 puts first_inc.call # output: 11 puts first_inc.call # output: 13 puts second_inc.call # output: 6 puts second_inc.call # output: 7 =begin All Output: 7 9 4 5 11 13 6 7 =end