def foreach(fn,iterable):
for x in iterable:
fn(x)
they just do it on every element and didn't yield or return something,i think it should be a built-in function and should be more faster than writing it with pure Python, but I didn't found it on the list,or it just called another name?or I just miss some points here?
def fn(*args):
for x in args:
dosomething
but I thought foreach is still welcome base on the two facts:
- In normal cases, people just don't care about the performance
- Sometime the API didn't accept iterable object and you can't rewrite its source.