Commit 6e54e874 authored by Reimers, Dominik's avatar Reimers, Dominik
Browse files

Changed package structure to be equal with pom declaration

parent c32b278f
Pipeline #64875 passed with stage
in 27 seconds
package main.java.common;
package core.common;
import java.util.ArrayList;
import java.util.Arrays;
......
package main.java.common;
package core.common;
public interface Effect<T> {
void apply(T t);
......
package main.java.common;
package core.common;
public abstract class Either<E, A> {
......
package main.java.common;
package core.common;
public interface Executable {
......
package main.java.common;
package core.common;
public interface Function<T, U> {
......
package main.java.common;
package core.common;
import java.util.Comparator;
......
package main.java.common;
package core.common;
import java.util.ArrayList;
import java.util.Arrays;
......@@ -8,9 +8,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.function.Consumer;
import static main.java.common.TailCall.ret;
import static main.java.common.TailCall.sus;
public abstract class List<A> {
protected abstract A head();
......@@ -186,8 +183,8 @@ public abstract class List<A> {
private TailCall<Tuple<List<A>, List<A>>> splitAt(List<A> acc, List<A> list, int i) {
return i == 0 || list.isEmpty()
? ret(new Tuple<>(list.reverse(), acc))
: sus(() -> splitAt(acc.cons(list.head()), list.tail(), i - 1));
? TailCall.ret(new Tuple<>(list.reverse(), acc))
: TailCall.sus(() -> splitAt(acc.cons(list.head()), list.tail(), i - 1));
}
public Tuple<List<A>, List<A>> splitAt_(int index) {
......@@ -283,8 +280,8 @@ public abstract class List<A> {
private TailCall<List<List<A>>> splitListAt(List<A> acc, List<A> list, int i) {
return i == 0 || list.isEmpty()
? ret(List.list(list.reverse(), acc))
: sus(() -> splitListAt(acc.cons(list.head()), list.tail(), i - 1));
? TailCall.ret(List.list(list.reverse(), acc))
: TailCall.sus(() -> splitListAt(acc.cons(list.head()), list.tail(), i - 1));
}
public List<List<A>> divide(int depth) {
......@@ -320,12 +317,12 @@ public abstract class List<A> {
private static <A> TailCall<Result<A>> first(final List<A> list, final Function<A, Boolean> f) {
if (list.isEmpty()) {
return ret(Result.<A> failure("Empty list"));
return TailCall.ret(Result.<A> failure("Empty list"));
}
if (f.apply(list.head())) {
return ret(Result.success(list.head()));
return TailCall.ret(Result.success(list.head()));
} else {
return sus(() -> first(list.tail(), f));
return TailCall.sus(() -> first(list.tail(), f));
}
}
......@@ -554,8 +551,8 @@ public abstract class List<A> {
private TailCall<StringBuilder> toString(StringBuilder acc, List<A> list) {
return list.isEmpty()
? ret(acc)
: sus(() -> toString(acc.append(list.head()).append(", "), list.tail()));
? TailCall.ret(acc)
: TailCall.sus(() -> toString(acc.append(list.head()).append(", "), list.tail()));
}
@Override
......@@ -567,8 +564,8 @@ public abstract class List<A> {
private TailCall<List<A>> drop_(List<A> list, int n) {
return n <= 0 || list.isEmpty()
? ret(list)
: sus(() -> drop_(list.tail(), n - 1));
? TailCall.ret(list)
: TailCall.sus(() -> drop_(list.tail(), n - 1));
}
@Override
......@@ -578,8 +575,8 @@ public abstract class List<A> {
private TailCall<List<A>> dropWhile_(List<A> list, Function<A, Boolean> f) {
return !list.isEmpty() && f.apply(list.head())
? sus(() -> dropWhile_(list.tail(), f))
: ret(list);
? TailCall.sus(() -> dropWhile_(list.tail(), f))
: TailCall.ret(list);
}
@Override
......@@ -589,8 +586,8 @@ public abstract class List<A> {
private TailCall<List<A>> reverse_(List<A> acc, List<A> list) {
return list.isEmpty()
? ret(acc)
: sus(() -> reverse_(new Cons<>(list.head(), acc), list.tail()));
? TailCall.ret(acc)
: TailCall.sus(() -> reverse_(new Cons<>(list.head(), acc), list.tail()));
}
@Override
......@@ -610,8 +607,8 @@ public abstract class List<A> {
private <B> TailCall<B> foldLeft(B acc, List<A> list, Function<B, Function<A, B>> f) {
return list.isEmpty()
? ret(acc)
: sus(() -> foldLeft(f.apply(acc).apply(list.head()), list.tail(), f));
? TailCall.ret(acc)
: TailCall.sus(() -> foldLeft(f.apply(acc).apply(list.head()), list.tail(), f));
}
@Override
......@@ -621,8 +618,8 @@ public abstract class List<A> {
private <B> TailCall<Tuple<B, List<A>>> foldLeft(B acc, B zero, List<A> list, Function<B, Function<A, B>> f) {
return list.isEmpty() || acc.equals(zero)
? ret(new Tuple<>(acc, list))
: sus(() -> foldLeft(f.apply(acc).apply(list.head()), zero, list.tail(), f));
? TailCall.ret(new Tuple<>(acc, list))
: TailCall.sus(() -> foldLeft(f.apply(acc).apply(list.head()), zero, list.tail(), f));
}
@Override
......@@ -796,8 +793,8 @@ public abstract class List<A> {
private static <A, B, C> TailCall<List<C>> zipWith_(List<C> acc, List<A> list1, List<B> list2, Function<A, Function<B, C>> f) {
return list1.isEmpty() || list2.isEmpty()
? ret(acc)
: sus(() -> zipWith_(
? TailCall.ret(acc)
: TailCall.sus(() -> zipWith_(
new Cons<>(f.apply(list1.head()).apply(list2.head()), acc),
list1.tail(), list2.tail(), f));
}
......@@ -816,10 +813,10 @@ public abstract class List<A> {
public static <A> TailCall<Boolean> hasSubList_(List<A> list, List<A> sub) {
return list.isEmpty()
? ret(sub.isEmpty())
? TailCall.ret(sub.isEmpty())
: startsWith(list, sub)
? ret(true)
: sus(() -> hasSubList_(list.tail(), sub));
? TailCall.ret(true)
: TailCall.sus(() -> hasSubList_(list.tail(), sub));
}
public static <A> Boolean startsWith(List<A> list, List<A> sub) {
......@@ -828,12 +825,12 @@ public abstract class List<A> {
private static <A> TailCall<Boolean> startsWith_(List<A> list, List<A> sub) {
return sub.isEmpty()
? ret(Boolean.TRUE)
? TailCall.ret(Boolean.TRUE)
: list.isEmpty()
? ret(Boolean.FALSE)
? TailCall.ret(Boolean.FALSE)
: list.head().equals(sub.head())
? sus(() -> startsWith_(list.tail(), sub.tail()))
: ret(Boolean.FALSE);
? TailCall.sus(() -> startsWith_(list.tail(), sub.tail()))
: TailCall.ret(Boolean.FALSE);
}
/**
......@@ -849,8 +846,8 @@ public abstract class List<A> {
private static <A, S> TailCall<List<A>> unfold(List<A> acc, S z, Function<S, Result<Tuple<A, S>>> f) {
Result<Tuple<A, S>> r = f.apply(z);
Result<TailCall<List<A>>> result = r.map(rt -> sus(() -> unfold(acc.cons(rt._1), rt._2, f)));
return result.getOrElse(ret(acc));
Result<TailCall<List<A>>> result = r.map(rt -> TailCall.sus(() -> unfold(acc.cons(rt._1), rt._2, f)));
return result.getOrElse(TailCall.ret(acc));
}
public static List<Integer> range(int start, int end) {
......
package main.java.common;
package core.common;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
......
package main.java.common;
package core.common;
public final class Nothing {
......
package main.java.common;
package core.common;
import java.util.Objects;
......
package main.java.common;
package core.common;
import main.java.io.IO;
import core.io.IO;
import java.io.Serializable;
import java.util.concurrent.Callable;
import static main.java.io.IO.unit;
import static core.io.IO.unit;
public abstract class Result<T> implements Serializable {
......
package main.java.common;
import static main.java.common.TailCall.ret;
import static main.java.common.TailCall.sus;
package core.common;
public abstract class Stream<A> {
......@@ -102,10 +99,10 @@ public abstract class Stream<A> {
private TailCall<Boolean> exists(Stream<A> s, Function<A, Boolean> p) {
return s.isEmpty()
? ret(false)
? TailCall.ret(false)
: p.apply(s.head()._1)
? ret(true)
: sus(() -> exists(s.tail(), p));
? TailCall.ret(true)
: TailCall.sus(() -> exists(s.tail(), p));
}
public Stream<A> dropWhile(Function<A, Boolean> f) {
......@@ -114,10 +111,10 @@ public abstract class Stream<A> {
private TailCall<Stream<A>> dropWhile(Stream<A> acc, Function<A, Boolean> f) {
return acc.isEmpty()
? ret(acc)
? TailCall.ret(acc)
: f.apply(acc.head()._1)
? sus(() -> dropWhile(acc.tail(), f))
: ret(acc);
? TailCall.sus(() -> dropWhile(acc.tail(), f))
: TailCall.ret(acc);
}
public List<A> toList() {
......@@ -126,8 +123,8 @@ public abstract class Stream<A> {
private TailCall<List<A>> toList(Stream<A> s, List<A> acc) {
return s.isEmpty()
? ret(acc)
: sus(() -> toList(s.tail(), List.cons(s.head()._1, acc)));
? TailCall.ret(acc)
: TailCall.sus(() -> toList(s.tail(), List.cons(s.head()._1, acc)));
}
public boolean hasSubSequence(Stream<A> s) {
......@@ -275,8 +272,8 @@ public abstract class Stream<A> {
public TailCall<Stream<A>> drop(Stream<A> acc, int n) {
return acc.isEmpty() || n <= 0
? ret(acc)
: sus(() -> drop(acc.tail(), n - 1));
? TailCall.ret(acc)
: TailCall.sus(() -> drop(acc.tail(), n - 1));
}
}
......@@ -371,8 +368,8 @@ public abstract class Stream<A> {
public static<T> TailCall<Stream<T>> fill(Stream<T> acc, int n, Supplier<T> elem) {
return n <= 0
? ret(acc)
: sus(() -> fill(new Cons<T>(elem, () -> acc), n - 1, elem));
? TailCall.ret(acc)
: TailCall.sus(() -> fill(new Cons<T>(elem, () -> acc), n - 1, elem));
}
public static Stream<Integer> fibs_() {
......
package main.java.common;
package core.common;
public interface Supplier<T> {
T get();
......
package main.java.common;
package core.common;
public abstract class TailCall<T> {
......
package main.java.common;
package core.common;
import java.util.Objects;
......
package main.java.common;
package core.common;
import java.util.Objects;
......
package main.java.io;
package core.io;
import main.java.common.Function;
import main.java.common.List;
import main.java.common.Nothing;
import main.java.common.Stream;
import main.java.common.Supplier;
import core.common.Function;
import core.common.List;
import core.common.Nothing;
import core.common.Stream;
import core.common.Supplier;
public interface IO<A> {
......
package main.java.io;
package core.io;
import main.java.common.Result;
import main.java.common.Tuple;
import core.common.Result;
import core.common.Tuple;
public interface Input {
......
package main.java.map;
package core.map;
import main.java.common.List;
import main.java.common.Result;
import main.java.common.Tree;
import main.java.common.Tuple;
import core.common.List;
import core.common.Result;
import core.common.Tree;
import core.common.Tuple;
public class Map<K, V> {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment