Skip to content

Commit

Permalink
Adding initial examples for streams
Browse files Browse the repository at this point in the history
  • Loading branch information
jabrena committed May 29, 2024
1 parent afc6bec commit 8f32b5e
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 622 deletions.
39 changes: 39 additions & 0 deletions training/src/main/java/info/jab/fp/stream/StreamExamples.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package info.jab.fp.stream;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Gatherers;

public class StreamExamples {

public void example1() {
var text = """
item1
item2
--
item11
item12
""";

var result = text.lines()
.gather(Gatherers.windowFixed(2))
.toList();
}

public void example2() {
var text = """
item1
item2
--
item11
item12
""";

var result = text.lines()
.gather(Gatherers.fold(() -> 0, (value, s) -> value + 1))
.findFirst().orElseThrow();

System.out.println(result);
}

}

This file was deleted.

24 changes: 0 additions & 24 deletions training/src/main/java/info/jab/fp/stream/gatherers/_11_map.java

This file was deleted.

This file was deleted.

31 changes: 0 additions & 31 deletions training/src/main/java/info/jab/fp/stream/gatherers/_13_fold.java

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8f32b5e

Please sign in to comment.