|
|
|
|
|
by hoosieree
601 days ago
|
|
They missed one: def agent(data, predicate, fns):
ps = map(predicate, data)
fs = map(lambda x:fns[x], ps)
return map(fs, data)
Basically you want to apply one of N functions to each of the items in your data iterable, so you have a predicate to figure out which function to apply first. The degenerate case is when you have just 2 functions and your predicate returns a boolean (0 or 1).This is "agent" from J: https://code.jsoftware.com/wiki/Vocabulary/atdot#agent |
|