Created
September 19, 2012 02:06
-
-
Save kinow/3747224 to your computer and use it in GitHub Desktop.
Ranges API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Outputs:
0 1 2 3 4 5 6 7 8 9
a b c