Skip to content

Instantly share code, notes, and snippets.

@kinow
Created September 19, 2012 02:06
Show Gist options
  • Save kinow/3747224 to your computer and use it in GitHub Desktop.
Save kinow/3747224 to your computer and use it in GitHub Desktop.
Ranges API
import org.apache.commons.functor.generator.loop.GenerateWhile;
import org.apache.commons.functor.generator.range.CharacterRange;
import org.apache.commons.functor.generator.range.IntegerRange;
import org.apache.commons.functor.generator.range.Ranges;
public class T {
public static void main(String[] args) {
UnaryProcedure<Object> printMe = new UnaryProcedure<Object>() {
public void run(Object obj) {
System.out.print(obj + " ");
}
};
IntegerRange integerRange = Ranges.integerRange(0, 10);
integerRange.run(printMe);
System.out.println();
CharacterRange charRange = Ranges.characterRange('a', 'c');
charRange.run(printMe);
}
}
@kinow
Copy link
Author

kinow commented Sep 19, 2012

Outputs:

0 1 2 3 4 5 6 7 8 9
a b c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment