commit fe0d801beac60e040d02264303c059825f2aaa73 Author: joachimschmidt557 Date: Thu Apr 11 21:08:53 2019 +0200 Initial commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..51a8bba --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..e42e4e6 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + mapfilterfold + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3a21537 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/bin/mapfilterfold/ListImplementation.class b/bin/mapfilterfold/ListImplementation.class new file mode 100644 index 0000000..0fb07c9 Binary files /dev/null and b/bin/mapfilterfold/ListImplementation.class differ diff --git a/src/mapfilterfold/ListImplementation.java b/src/mapfilterfold/ListImplementation.java new file mode 100644 index 0000000..f9ec5c5 --- /dev/null +++ b/src/mapfilterfold/ListImplementation.java @@ -0,0 +1,29 @@ +package mapfilterfold; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; +import java.util.function.Predicate; + +public class ListImplementation { + + public static List map(Function func, List list) { + + List result = new ArrayList(list.size()); + for (int i = 0; i < list.size(); i++) + result.set(i, func.apply(list.get(i))); + return result; + + } + + public static List filter(Predicate pred, List list) { + + List result = new ArrayList(list.size()); + for (int i = 0; i < list.size(); i++) + if (pred.test(list.get(i))) + result.add(list.get(i)); + return result; + + } + +}