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)); }
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); }
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())); }
private TailCall<StringBuilder> toString(StringBuilder acc, List<A> list) { return list.isEmpty() ? ret(acc) : sus(() -> toString(acc.append(list.head()).append(", "), list.tail())); }