Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Jun 10, 2023
2 parents 6cd5410 + 97e094c commit 596e8f9
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,21 @@ Collection<String> filtered = new ListOf<>(
To flatten one iterable:
```java
new Joined<>(
new Mapped<>(
new Mapped<IterableOf>(
iter -> new IterableOf<>(
new ListOf<>(iter).toArray(new Integer[]{})
),
new IterableOf<>(1, 2, 3, 4, 5, 6))
new IterableOf<>(1, 2, 3, 4, 5, 6)
)
); // Iterable<Integer>
```

To flatten and join several iterables:
```java
new Joined<>(
new Mapped<>(
new Mapped<IterableOf>(
iter -> new IterableOf<>(
new ListOf<>(iter).toArray(new Integer[]{})
new Joined<>(iter)
),
new Joined<>(
new IterableOf<>(new IterableOf<>(1, 2, 3)),
Expand All @@ -168,7 +168,8 @@ new And(
new FuncOf<>(
input -> {
System.out.printf("Item: %s\n", input);
}
},
new True()
),
new IterableOf<>("how", "are", "you", "?")
)
Expand All @@ -182,19 +183,22 @@ new ForEach<String>(
input -> System.out.printf(
"Item: %s\n", input
)
).exec("how", "are", "you", "?");
).exec(new IterableOf("how", "are", "you", "?"));
```

To sort a list of words in the file:

```java
List<Text> sorted = new ListOf<>(
new Sorted<>(
new Split(
new TextOf(
new File("/tmp/names.txt")
),
new TextOf("\\s+")
new Mapped<>(
text -> new ComparableText(text),
new Split(
new TextOf(
new File("/tmp/names.txt")
),
new TextOf("\\s+")
)
)
)
);
Expand All @@ -205,7 +209,7 @@ To count elements in an iterable:
```java
int total = new LengthOf(
new IterableOf<>("how", "are", "you")
).intValue();
).value().intValue();
```

To create a set of elements by providing variable arguments:
Expand Down Expand Up @@ -267,6 +271,7 @@ This is its object-oriented alternative (no streams!):
new And(
n -> {
System.out.printf("Hello, %s!\n", n);
return new True().value();
},
names
).value();
Expand Down Expand Up @@ -313,7 +318,7 @@ To format an `OffsetDateTime` into a `Text`:

```java
final OffsetDateTime date = ...;
final String text = new TextOf(date).asString();
final String text = new TextOfDateTime(date).asString();
```

## Our objects vs. their static methods
Expand Down

0 comments on commit 596e8f9

Please sign in to comment.