Skip to content

Commit 5be2bd8

Browse files
committed
adding missing javadocs
1 parent 9040621 commit 5be2bd8

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎src/main/java/com/jnape/palatable/lambda/functions/builtin/fn2/Intersperse.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
import static com.jnape.palatable.lambda.functions.builtin.fn1.Tail.tail;
77
import static com.jnape.palatable.lambda.functions.builtin.fn2.PrependAll.prependAll;
88

9+
/**
10+
* Lazily inject the provided separator value between each value in the supplied <code>Iterable</code>. An empty
11+
* <code>Iterable</code> is left untouched.
12+
*
13+
* @param <A> the Iterable parameter type
14+
* @see PrependAll
15+
*/
916
public final class Intersperse<A> implements Fn2<A, Iterable<A>, Iterable<A>> {
1017

1118
private static final Intersperse INSTANCE = new Intersperse();

‎src/main/java/com/jnape/palatable/lambda/functions/builtin/fn2/PrependAll.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
import static com.jnape.palatable.lambda.functions.builtin.fn2.Cons.cons;
99
import static java.util.Collections.emptyList;
1010

11+
/**
12+
* Lazily prepend each value with of the <code>Iterable</code> with the supplied separator value. An empty
13+
* <code>Iterable</code> is left untouched.
14+
*
15+
* @param <A> the Iterable parameter type
16+
* @see Intersperse
17+
*/
1118
public final class PrependAll<A> implements Fn2<A, Iterable<A>, Iterable<A>> {
1219

1320
private static final PrependAll INSTANCE = new PrependAll();

‎src/main/java/com/jnape/palatable/lambda/functions/builtin/fn2/ToMap.java‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import java.util.Map;
77
import java.util.function.Supplier;
88

9+
import static com.jnape.palatable.lambda.functions.builtin.fn3.FoldLeft.foldLeft;
10+
911
/**
1012
* Given a {@link Supplier} of some {@link Map} <code>M</code>, create an instance of <code>M</code> and put
1113
* all of the entries in the provided <code>Iterable</code> into the instance. Note that instances of <code>M</code>
@@ -24,9 +26,10 @@ private ToMap() {
2426

2527
@Override
2628
public M apply(Supplier<M> mSupplier, Iterable<Map.Entry<K, V>> entries) {
27-
M m = mSupplier.get();
28-
entries.forEach(kv -> m.put(kv.getKey(), kv.getValue()));
29-
return m;
29+
return foldLeft((m, kv) -> {
30+
m.put(kv.getKey(), kv.getValue());
31+
return m;
32+
}, mSupplier.get(), entries);
3033
}
3134

3235
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)