Skip to content

Instantly share code, notes, and snippets.

@lomholdt
Created February 10, 2016 23:39
Show Gist options
  • Save lomholdt/6e4e614c4023d8f62d0c to your computer and use it in GitHub Desktop.
Save lomholdt/6e4e614c4023d8f62d0c to your computer and use it in GitHub Desktop.
public <A, B> B foldLeft(List<A> l, B z, Function2<B, A, B> f) {
List list;
do {
if (Nil..MODULE$.equals((Object)(list = l))) {
B b = z;
return b;
}
if (!(list instanceof .colon.colon)) break;
.colon.colon colon2 = (.colon.colon)list;
Object h = colon2.head();
List t = colon2.tl$1();
Object object = f.apply(z, h);
z = object;
l = t;
} while (true);
throw new MatchError(list);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment