Commits

Micha Kops  committed 85d673e

functionaljava array filtering example added.

  • Participants
  • Parent commits cf5125a

Comments (0)

Files changed (1)

File src/main/java/com/hascode/tutorial/ArrayFilteringExample.java

+package com.hascode.tutorial;
+
+import static fj.data.Array.array;
+import fj.Effect;
+import fj.F;
+import fj.data.Array;
+
+public class ArrayFilteringExample {
+	public static void main(final String[] args) {
+		final Array<String> a = array("This", "is", "an", "example");
+		final Array<String> b = a.filter(new F<String, Boolean>() {
+			@Override
+			public Boolean f(final String a) {
+				return a.matches(".*i.*");
+			}
+		});
+		b.foreach(new Effect<String>() {
+			@Override
+			public void e(final String a) {
+				System.out.println(a);
+			}
+		}); // output: This is
+	}
+}