Permalink
Browse files

Changing artifact names to something more Maven friendky. Turning the…

… functionaljava examples into tests
  • Loading branch information...
1 parent 4ad46ac commit 8d355c3e6e17e574f8903020e28b9ebedc3203bf @hraberg committed Oct 28, 2011
Showing with 836 additions and 304 deletions.
  1. +3 −2 .classpath
  2. +18 −17 .project
  3. +3 −3 README.markdown
  4. +17 −15 build.xml
  5. +0 −22 src/example/java/lambda/functionaljava/euler/Problem1.java
  6. +0 −29 src/example/java/lambda/functionaljava/euler/Problem2.java
  7. +0 −61 src/example/java/lambda/functionaljava/euler/Problem3.java
  8. +0 −27 src/example/java/lambda/functionaljava/euler/Problem4.java
  9. +2 −2 src/example/project/.classpath
  10. +4 −4 src/example/project/build.xml
  11. +207 −0 src/java-spikes/lambda/DataSpike.java
  12. +260 −0 src/java-spikes/lambda/MatcherSpike.java
  13. +144 −0 src/java-spikes/lambda/SchemeSpike.java
  14. +26 −0 src/main/java/lambda/Fn0.java
  15. +2 −0 src/main/java/lambda/annotation/LambdaLocal.java
  16. +6 −14 src/main/java/lambda/support/expression/LambdaExpressionTrees.java
  17. +2 −2 src/main/java/lambda/weaving/LambdaLoader.java
  18. +3 −0 src/main/java/lambda/weaving/tree/LambdaTreeWeaver.java
  19. +1 −0 src/test/java/lambda/LambdaTest.java
  20. +1 −0 src/test/java/lambda/enumerable/collection/EnumerableCollectionsTest.java
  21. +9 −7 src/{example/java/lambda → test/java/lambda/support}/functionaljava/Array_bind.java
  22. +9 −6 src/{example/java/lambda → test/java/lambda/support}/functionaljava/Array_exists.java
  23. +9 −7 src/{example/java/lambda → test/java/lambda/support}/functionaljava/Array_filter.java
  24. +8 −6 src/{example/java/lambda → test/java/lambda/support}/functionaljava/Array_foldLeft.java
  25. +8 −6 src/{example/java/lambda → test/java/lambda/support}/functionaljava/Array_forall.java
  26. +9 −7 src/{example/java/lambda → test/java/lambda/support}/functionaljava/Array_map.java
  27. +9 −7 src/{example/java/lambda → test/java/lambda/support}/functionaljava/List_apply.java
  28. +9 −7 src/{example/java/lambda → test/java/lambda/support}/functionaljava/List_map.java
  29. +9 −7 src/{example/java/lambda → test/java/lambda/support}/functionaljava/List_sort.java
  30. +11 −9 src/{example/java/lambda → test/java/lambda/support}/functionaljava/Option_bind.java
  31. +11 −9 src/{example/java/lambda → test/java/lambda/support}/functionaljava/Option_filter.java
  32. +10 −8 src/{example/java/lambda → test/java/lambda/support}/functionaljava/Option_map.java
  33. +9 −7 src/{example/java/lambda → test/java/lambda/support}/functionaljava/Primes2.java
  34. +9 −7 src/{example/java/lambda → test/java/lambda/support}/functionaljava/Set_map.java
  35. +8 −6 src/{example/java/lambda → test/java/lambda/support}/functionaljava/TreeMap_Update.java
View
@@ -5,6 +5,9 @@
<classpathentry kind="src" output="target/example-classes" path="src/example/java"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/jruby"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/rubyspec"/>
+ <classpathentry kind="src" output="target/scala-classes" path="src/main/scala"/>
+ <classpathentry kind="src" output="target/scala-test-classes" path="src/test/scala"/>
+ <classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/junit-4.7.jar" sourcepath="lib/src/junit-4.7-sources.jar"/>
<classpathentry kind="lib" path="lib/extra166y.jar" sourcepath="lib/src/extra166y.zip"/>
@@ -19,8 +22,6 @@
<classpathentry kind="lib" path="lib/ecj-3.5.2.jar" sourcepath="lib/src/ecjsrc-3.5.2.zip"/>
<classpathentry kind="lib" path="lib/scala-compiler-2.8.0.final.jar"/>
<classpathentry kind="lib" path="lib/scala-library-2.8.0.final.jar"/>
- <classpathentry kind="lib" path="target/scala-classes"/>
- <classpathentry kind="lib" path="target/scala-test-classes"/>
<classpathentry kind="lib" path="lib/functionaljava-3.0.jar" sourcepath="lib/src/functionaljava-3.0-sources.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
View
@@ -1,17 +1,18 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>enumerable</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>enumerable</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.scala-ide.sdt.core.scalabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.scala-ide.sdt.core.scalanature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
View
@@ -52,7 +52,7 @@ Block parameters are defined using annotated static fields. For more examples se
Enumerable.java is packaged as a [java agent](http://java.sun.com/javase/6/docs/api/java/lang/instrument/package-summary.html). ASM has been moved to a local package (lambda.asm).
- java -javaagent:enumerable-agent-<version>.jar [...]
+ java -javaagent:enumerable-java-<version>.jar [...]
Look at [LamdaLoader](http://github.com/hraberg/enumerable/blob/master/src/main/java/lambda/weaving/LambdaLoader.java) if you have different class loading needs.
@@ -71,13 +71,13 @@ To avoid the use of the agent, or any other non standard class loading, you can
java -cp <project class path> lambda.weaving.LambdaCompiler project.jar
-The jar will be compiled and rebuilt in place. The runtime dependency on `enumerable-agent-<version>.jar` as a library remains after AOT compilation.
+The jar will be compiled and rebuilt in place. The runtime dependency on `enumerable-java-<version>.jar` as a library remains after AOT compilation.
See the targets `aot-compile-tests` and `aot-tests` in [build.xml](http://github.com/hraberg/enumerable/blob/master/build.xml) for an example.
### Binary Distribution
-`enumerable-agent-<version>.jar` is both the actual library, and the java agent enabling load time weaving of lambdas.
+`enumerable-java-<version>.jar` is both the actual library, and the java agent enabling load time weaving of lambdas.
The binary distribution, when downloaded as a .tgz archive, or built using `ant dist`, doubles as an example project which can be directly imported into Eclipse.
Open *lambda.enumerable.EnumerableExample* to get started. The example bootstraps itself if needed, so you don't need to configure the javaagent. There's also a `build.xml` in the `example` folder, which includes targets for AOT compilation.
View
@@ -106,14 +106,14 @@
</target>
<target name="agent-jar-uptodate">
- <uptodate property="jarjar.notRequired" targetfile="target/enumerable-agent-${enumerable.version}.jar">
+ <uptodate property="jarjar.notRequired" targetfile="target/enumerable-java-${enumerable.version}.jar">
<srcfiles dir="src/main/java" includes="**/*" />
<srcfiles dir="src/main/scala" includes="**/*" />
</uptodate>
</target>
<target name="agent-jar" unless="jarjar.notRequired" depends="build,agent-jar-uptodate">
- <jarjar jarfile="target/enumerable-agent-${enumerable.version}.jar">
+ <jarjar jarfile="target/enumerable-java-${enumerable.version}.jar">
<fileset dir="target/classes" />
<zipfileset src="lib/asm-all-${asm.version}.jar" />
<rule pattern="org.objectweb.asm.**" result="lambda.asm.@1" />
@@ -123,13 +123,13 @@
<attribute name="Can-Retransform-Classes" value="true" />
</manifest>
</jarjar>
- <jar jarfile="target/enumerable-agent-${enumerable.version}.jar" update="true" encoding="UTF-8">
+ <jar jarfile="target/enumerable-java-${enumerable.version}.jar" update="true" encoding="UTF-8">
<fileset dir="target/scala-classes" />
</jar>
</target>
<target name="agent-jar-slim" unless="jarjar.notRequired" depends="agent-jar">
- <jarjar jarfile="target/enumerable-agent-slim-${enumerable.version}.jar">
+ <jarjar jarfile="target/enumerable-java-slim-${enumerable.version}.jar">
<fileset dir="target/classes">
<exclude name="lambda/*.class" />
<exclude name="lambda/support/**/*.class" />
@@ -144,7 +144,7 @@
<attribute name="Can-Retransform-Classes" value="true" />
</manifest>
</jarjar>
- <jar jarfile="target/enumerable-agent-slim-${enumerable.version}.jar" update="true" encoding="UTF-8">
+ <jar jarfile="target/enumerable-java-slim-${enumerable.version}.jar" update="true" encoding="UTF-8">
<fileset dir="target/scala-classes" />
</jar>
</target>
@@ -153,7 +153,7 @@
<target name="tests" depends="agent-jar">
<mkdir dir="target/junit" />
<junit fork="yes" forkmode="once" printsummary="withOutAndErr" failureproperty="tests.failed">
- <jvmarg value="-javaagent:target/enumerable-agent-${enumerable.version}.jar" />
+ <jvmarg value="-javaagent:target/enumerable-java-${enumerable.version}.jar" />
<sysproperty key="lambda.weaving.debug" value="${lambda.weaving.debug}" />
<sysproperty key="lambda.weaving.debug.classes.dir" value="${lambda.weaving.debug.classes.dir}" />
<sysproperty key="lambda.weaving.debug.dev" value="${lambda.weaving.debug.dev}" />
@@ -162,6 +162,7 @@
<batchtest todir="target/junit">
<fileset dir="src/test/java">
<include name="**/*Test.java" />
+ <include name="**/functionaljava/*_*.java" />
<exclude name="**/CoreEnumerableRubySpecSuiteTest.java" />
</fileset>
</batchtest>
@@ -183,7 +184,7 @@
</target>
<target name="test-jar" depends="build">
- <jar jarfile="target/enumerable-test-${enumerable.version}.jar" encoding="UTF-8">
+ <jar jarfile="target/enumerable-java-${enumerable.version}-test.jar" encoding="UTF-8">
<fileset dir="target/test-classes" />
<fileset dir="target/scala-test-classes" />
<fileset dir="target/example-classes">
@@ -194,7 +195,7 @@
<target name="aot-compile-tests" depends="test-jar">
<java fork="yes" classname="lambda.weaving.LambdaCompiler" failonerror="yes">
- <arg value="target/enumerable-test-${enumerable.version}.jar" />
+ <arg value="target/enumerable-java-${enumerable.version}-test.jar" />
<sysproperty key="lambda.weaving.debug" value="${lambda.weaving.debug}" />
<sysproperty key="lambda.weaving.debug.classes.dir" value="${lambda.weaving.debug.classes.dir}" />
<sysproperty key="lambda.weaving.debug.dev" value="${lambda.weaving.debug.dev}" />
@@ -211,12 +212,13 @@
<sysproperty key="lambda.weaving.debug.dev" value="${lambda.weaving.debug.dev}" />
<sysproperty key="lambda.weaving.skipped.packages" value="${lambda.weaving.skipped.packages}" />
<classpath refid="enumerable.classpath" />
- <classpath location="target/enumerable-test-${enumerable.version}.jar" />
+ <classpath location="target/enumerable-java-${enumerable.version}-test.jar" />
<classpath location="lib/junit-4.7.jar" />
<classpath location="lib/scala-compiler-${scala.version}.jar" />
<batchtest todir="target/junit-aot">
<fileset dir="src/test/java">
<include name="**/*Test.java" />
+ <include name="**/functionaljava/*_*.java" />
<exclude name="**/weaving/**/*Test.java" />
<exclude name="**/CoreEnumerableRubySpecSuiteTest.java" />
</fileset>
@@ -231,7 +233,7 @@
<target name="example-with-agent" depends="agent-jar">
<java fork="yes" classname="lambda.enumerable.EnumerableExample" failonerror="yes">
- <jvmarg value="-javaagent:target/enumerable-agent-${enumerable.version}.jar" />
+ <jvmarg value="-javaagent:target/enumerable-java-${enumerable.version}.jar" />
<sysproperty key="lambda.weaving.debug" value="${lambda.weaving.debug}" />
<sysproperty key="lambda.weaving.debug.classes.dir" value="${lambda.weaving.debug.classes.dir}" />
<sysproperty key="lambda.weaving.debug.dev" value="${lambda.weaving.debug.dev}" />
@@ -242,7 +244,7 @@
<target name="example-with-verifier" depends="agent-jar">
<java fork="yes" classname="lambda.enumerable.EnumerableExample" failonerror="yes">
- <jvmarg value="-javaagent:target/enumerable-agent-${enumerable.version}.jar" />
+ <jvmarg value="-javaagent:target/enumerable-java-${enumerable.version}.jar" />
<sysproperty key="lambda.weaving.debug" value="true" />
<sysproperty key="lambda.weaving.debug.classes.dir" value="${lambda.weaving.debug.classes.dir}" />
<sysproperty key="lambda.weaving.debug.dev" value="${lambda.weaving.debug.dev}" />
@@ -267,7 +269,7 @@
<target name="microbench" depends="agent-jar">
<java fork="yes" classname="lambda.MicroBench" failonerror="yes">
- <jvmarg value="-javaagent:target/enumerable-agent-${enumerable.version}.jar" />
+ <jvmarg value="-javaagent:target/enumerable-java-${enumerable.version}.jar" />
<sysproperty key="lambda.weaving.debug" value="${lambda.weaving.debug}" />
<sysproperty key="lambda.weaving.debug.classes.dir" value="${lambda.weaving.debug.classes.dir}" />
<sysproperty key="lambda.weaving.debug.dev" value="${lambda.weaving.debug.dev}" />
@@ -277,14 +279,14 @@
</target>
<target name="source-jar">
- <jar jarfile="target/enumerable-sources-${enumerable.version}.jar" encoding="UTF-8">
+ <jar jarfile="target/enumerable-java-${enumerable.version}-sources.jar" encoding="UTF-8">
<fileset dir="src/main/java" />
<fileset dir="src/main/scala" />
</jar>
</target>
<target name="test-source-jar">
- <jar jarfile="target/enumerable-test-sources-${enumerable.version}.jar" encoding="UTF-8">
+ <jar jarfile="target/enumerable-java-${enumerable.version}-test-sources.jar" encoding="UTF-8">
<fileset dir="src/test/java" />
<fileset dir="src/test/jruby" />
<fileset dir="src/test/rubyspec" />
@@ -293,7 +295,7 @@
</target>
<target name="javadoc-jar" depends="javadoc">
- <jar jarfile="target/enumerable-javadoc-${enumerable.version}.jar" encoding="UTF-8">
+ <jar jarfile="target/enumerable-java-${enumerable.version}-javadoc.jar" encoding="UTF-8">
<fileset dir="target/apidocs" />
</jar>
</target>
@@ -1,22 +0,0 @@
-package lambda.functionaljava.euler;
-
-import static fj.data.List.*;
-import static fj.function.Integers.*;
-import static java.lang.System.*;
-import static lambda.support.functionaljava.LambdaFunctionalJava.*;
-import lambda.annotation.LambdaParameter;
-import lambda.weaving.LambdaLoader;
-
-/**
- * Add all the natural numbers below one thousand that are multiples of 3 or 5.
- */
-public class Problem1 {
- @LambdaParameter
- static Integer a;
-
- public static void main(final String[] args) {
- LambdaLoader.bootstrapMainIfNotEnabledAndExitUponItsReturn(args);
-
- out.println(sum(range(0, 1000).filter(λ(a, a % 3 == 0 || a % 5 == 0))));
- }
-}
@@ -1,29 +0,0 @@
-package lambda.functionaljava.euler;
-
-import static fj.Ord.*;
-import static fj.data.Stream.*;
-import static fj.function.Integers.*;
-import static java.lang.System.*;
-import static lambda.support.functionaljava.LambdaFunctionalJava.*;
-import lambda.annotation.LambdaParameter;
-import lambda.weaving.LambdaLoader;
-import fj.F2;
-import fj.data.Stream;
-
-/**
- * Find the sum of all the even-valued terms in the Fibonacci sequence which do
- * not exceed four million.
- */
-public class Problem2 {
- @LambdaParameter
- static Integer a, b;
-
- static F2<Integer, Integer, Stream<Integer>> fib;
-
- public static void main(final String[] args) {
- LambdaLoader.bootstrapMainIfNotEnabledAndExitUponItsReturn(args);
-
- final Stream<Integer> fibs = (fib = λ(a, b, cons(a, fib.curry().f(b).lazy().f(a + b)))).f(1, 2);
- out.println(sum(fibs.filter(λ(a, a % 2 == 0)).takeWhile(intOrd.isLessThan(4000001)).toList()));
- }
-}
@@ -1,61 +0,0 @@
-package lambda.functionaljava.euler;
-
-import static fj.Ord.*;
-import static fj.Show.*;
-import static fj.data.Enumerator.*;
-import static fj.data.Natural.*;
-import static fj.data.Stream.*;
-import static lambda.support.functionaljava.LambdaFunctionalJava.*;
-import lambda.annotation.LambdaParameter;
-import lambda.weaving.LambdaLoader;
-import fj.P1;
-import fj.data.Natural;
-import fj.data.Stream;
-import fj.data.vector.V2;
-
-/**
- * Find the largest prime factor of a composite number.
- */
-public class Problem3 {
- @LambdaParameter
- static Natural n;
-
- // An infinite stream of all the primes.
- public static final Stream<Natural> primes = primes();
-
- private static Stream<Natural> primes() {
- return cons(natural(2).some(),
- p1(forever(naturalEnumerator, natural(3).some(), 2).filter(λ(n, primeFactors(n).length() == 1))));
- }
-
- // Finds factors of a given number.
- public static Stream<Natural> factor(final Natural n, final Natural p, final P1<Stream<Natural>> ps) {
- Stream<Natural> ns = cons(p, ps);
- Stream<Natural> ret = nil();
- while (ns.isNotEmpty() && ret.isEmpty()) {
- final Natural h = ns.head();
- final P1<Stream<Natural>> t = ns.tail();
- if (naturalOrd.isGreaterThan(h.multiply(h), n))
- ret = single(n);
- else {
- final V2<Natural> dm = n.divmod(h);
- if (naturalOrd.eq(dm._2(), ZERO))
- ret = cons(h, p1(factor(dm._1(), h, t)));
- else
- ns = ns.tail()._1();
- }
- }
- return ret;
- }
-
- // Finds the prime factors of a given number.
- public static Stream<Natural> primeFactors(final Natural n) {
- return factor(n, natural(2).some(), primes.tail());
- }
-
- public static void main(final String[] args) {
- LambdaLoader.bootstrapMainIfNotEnabledAndExitUponItsReturn(args);
-
- naturalShow.println(primeFactors(natural(600851475143L).some()).last());
- }
-}
@@ -1,27 +0,0 @@
-package lambda.functionaljava.euler;
-
-import static fj.Equal.*;
-import static fj.Function.*;
-import static fj.Ord.*;
-import static fj.Show.*;
-import static fj.data.Stream.*;
-import static fj.function.Integers.*;
-import static lambda.support.functionaljava.LambdaFunctionalJava.*;
-import lambda.annotation.LambdaParameter;
-import lambda.weaving.LambdaLoader;
-import fj.data.Stream;
-
-/**
- * Find the largest palindrome made from the product of two 3-digit numbers.
- */
-public class Problem4 {
- @LambdaParameter
- static Integer i;
-
- public static void main(final String[] args) {
- LambdaLoader.bootstrapMainIfNotEnabledAndExitUponItsReturn(args);
-
- final Stream<Integer> tdl = iterate(flip(subtract).f(1), 999).takeWhile(intOrd.isGreaterThan(99));
- intShow.println(tdl.tails().bind(tdl.zipWith(multiply)).filter(λ(i, streamEqual(charEqual).eq(intShow.show(i).reverse().take(3), intShow.show(i).take(3)))).foldLeft1(intOrd.max));
- }
-}
@@ -2,9 +2,9 @@
<classpath>
<classpathentry kind="src" path="example/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="enumerable-agent-@enumerable.version@.jar" sourcepath="enumerable-sources-@enumerable.version@.jar">
+ <classpathentry kind="lib" path="enumerable-java-@enumerable.version@.jar" sourcepath="enumerable-@enumerable.version@-sources.jar">
<attributes>
- <attribute name="javadoc_location" value="jar:platform:/resource/enumerable-java-example/enumerable-javadoc-@enumerable.version@.jar!/"/>
+ <attribute name="javadoc_location" value="jar:platform:/resource/enumerable-java-example/enumerable-@enumerable.version@-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="example/target/classes"/>
Oops, something went wrong.

0 comments on commit 8d355c3

Please sign in to comment.