Files
dholle c375235680
SonarQube Scan / SonarQube Trigger (push) Failing after 2m48s
Fix tests
2026-09-09 16:11:42 +02:00

13 lines
472 B
Java

public sealed interface List<T> permits Cons, Empty {}
public record Cons<T>(T a, List<T> l) implements List<T> {}
public record Empty<T>() implements List<T> {}
public record Pair<T1, T2>(T1 a, T2 b) {}
public class PatternMatching {
// Anmerkung: Typ muss angegeben werden
public <A, B> Cons<Pair<A, B>> zip(Cons(x, xs), Cons(y, ys)) {
return new Cons<>(new Pair<>(x, y), zip(xs, ys));
}
public zip(Empty(), Empty()) { return new Empty<>(); }
}