Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- RFID
- Programming
- Linux
- Book review
- Spain
- Kuala Lumpur
- Python
- MySQL
- essay
- history
- django
- hbase
- erlang
- programming_book
- management
- Software Engineering
- Malaysia
- agile
- Artificial Intelligence
- Book
- France
- comic agile
- QT
- web
- leadership
- ubuntu
- Italy
- program
- hadoop
- Java
Archives
- Today
- Total
Do not use loops for list operations - Functionaljava 본문
2011/04/26 - [Programming/Java] - Do not use loops for list operations
2011/04/28 - [Programming/Java] - Do not use loops for list operations
2011/04/28 - [Programming/Java] - Do not use loop for list iterations - lamdaj
2011/04/28 - [Programming/Java] - Do not use loops for list operations
2011/04/28 - [Programming/Java] - Do not use loop for list iterations - lamdaj
import fj.data.List; import fj.Effect; import fj.F; import static fj.data.List.single; // item 3 from http://codemonkeyism.com/generation-java-programming-style // http://code.google.com/p/functionaljava // $ javac -cp .:./functionaljava/functionaljava.jar TestFunctionaljava.java -Xlint public class TestFunctionaljava { private static final Effect e; static { e = new Effect<Person>() { public void e(final Person p) { System.out.println(p); } }; } private static final F<Person, Boolean> hasAge = new F<Person, Boolean>() { public Boolean f(final Person p) { return 16 < p.getAge(); } }; public static void main(final String[] args) { final List<Person> persons = List.list( new Person("A", 15), new Person("B", 16), new Person("C", 17)); persons.foreach(e); final List<Person> beerDrinkers = persons.filter(hasAge); beerDrinkers.foreach(e); } } class Person { public final String name; public final int age; public Person(String name, int age) { this.name = name; this.age = age; } public int getAge() { return this.age; } public String toString(){ return name + " = " + age; } }
Comments