Skip to content

Commit c8e7095

Browse files
committed
Added module to consume the snapshot from Sonatype
1 parent f6cc29f commit c8e7095

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ allprojects {
1111

1212
snapshotAppendix = "-SNAPSHOT"
1313
fjVersion = fjBaseVersion + (isSnapshot ? snapshotAppendix : "")
14+
fjConsumeVersion = fjVersion
1415

1516
projectTitle = "Functional Java"
1617
projectName = "functionaljava"

consume/build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
apply plugin: 'java'
3+
4+
defaultTasks 'build'
5+
6+
repositories {
7+
mavenCentral()
8+
maven {
9+
url sonatypeRepositoryUrl
10+
}
11+
}
12+
13+
dependencies {
14+
compile("org.functionaljava:functionaljava:$fjConsumeVersion")
15+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package fj.consume.euler;
2+
3+
import fj.F;
4+
import fj.data.Stream;
5+
6+
import static fj.data.List.range;
7+
import static fj.function.Integers.sum;
8+
9+
import static java.lang.System.out;
10+
11+
/**
12+
* Add all the natural numbers below one thousand that are multiples of 3 or 5.
13+
*/
14+
public class Problem1 {
15+
16+
public static void main(final String[] args) {
17+
java7();
18+
java8();
19+
}
20+
21+
public static void java7() {
22+
out.println(sum(range(0, 1000).filter(new F<Integer, Boolean>() {
23+
public Boolean f(final Integer a) { return a % 3 == 0 || a % 5 == 0;}
24+
})));
25+
}
26+
27+
public static void java8() {
28+
out.println(Stream.range(0, 1000).filter(i -> i % 3 == 0 || i % 5 == 0).foldLeft((acc, i) -> acc + i, 0));
29+
}
30+
31+
}

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
//include 'core', 'demo', 'tests'
3-
include 'core', 'demo'
3+
include 'core', 'demo', "consume"
44
// The final Java 8 release, (build 1.8.0-b132) does not work with Gradle and the Scala plugin
55
// see http://issues.gradle.org/browse/GRADLE-3023
66

0 commit comments

Comments
 (0)