Skip to content

Small bug fixes #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/learnrxjava/ComposableList.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,9 @@ public ComposableList<Integer> exercise9() {
Unfortunately List doesn't have a concatMap method and there's no way for us to add one. However we _can_ define a static method concatMap. The concatMap method accepts a ComposableList<T> , a function that accepts a single value and returns a collection (Function<T, ComposableList<R>> ), and returns a flat list of the results (ComposableList<R> ).
*/

public static <T, R> ComposableList<R> concatMap(ComposableList<T> that, Function<T, List<R>> projectionFunctionThatReturnsList) {
public <R> ComposableList<R> concatMap(Function<T, ComposableList<R>> projectionFunctionThatReturnsList) {
ComposableList<R> results = new ComposableList<R>();
for (T itemInList : that) {
for (T itemInList : this) {
// ------------ INSERT CODE HERE! ----------------------------
// Apply the projection function to each item in the list.
// This will create _another_ list. Then loop through each
Expand Down Expand Up @@ -618,7 +618,7 @@ public ComposableList<T> reduce(BiFunction<T, T, T> combiner) {
// the previous computation back into the combiner function until
// we've exhausted the entire list and are left with only one function.
while (counter < this.size()) {
accumulatedValue = combiner.apply(accumulatedValue, this.get(1));
accumulatedValue = combiner.apply(accumulatedValue, this.get(counter));
counter++;
}

Expand All @@ -643,7 +643,7 @@ public <R> ComposableList<R> reduce(R initialValue, BiFunction<R, T, R> combiner
// the previous computation back into the combiner function until
// we've exhausted the entire list and are left with only one function.
while (counter < this.size()) {
accumulatedValue = combiner.apply(accumulatedValue, this.get(0));
accumulatedValue = combiner.apply(accumulatedValue, this.get(counter));
counter++;
}

Expand Down Expand Up @@ -749,7 +749,7 @@ public ComposableList<Map<Integer, String>> exercise18() {

This is a variation of the problem we solved earlier, where we retrieved the url of the boxart with a width of 150px. This time we'll use reduce() instead of filter() to retrieve the smallest box art in the boxarts list.
*/
public JSON exercise19() {
public ComposableList<JSON> exercise19() {
ComposableList<MovieList> movieLists = ComposableList.of(
new MovieList(
"New Releases",
Expand Down