by Garph · 7y ago · 0 comments
def do(x, fs):
for f in fs:
x = f(x)
return x
Which allows left-to-right style programming do(list, filter, partial(map, int), sum)
I haven't put this into production code yet, but love pipelining scripts with doThey differentiate thread first/last for Fns with arity > 1, just like Clojure.
CompletableFuture<Member> asyncProjectMembers =
Async.pipeline(Accounts.where("id >= ?", 1000);,
(accounts) -> accounts.loadProjects("updated_at >= ?", Instant.now().minusDays(30)),
(projects) -> projects.loadMembers());
If you assign the intermediates to variables, each instance will have associated with it the related collection that's queried while avoiding N+1's.