foreach example first class citizen
This commit is contained in:
parent
b87bcb3b30
commit
26100e1c1e
1 changed files with 10 additions and 0 deletions
10
python-temel/foreach.py
Normal file
10
python-temel/foreach.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
def foreach(l, f):
|
||||
for x in l:
|
||||
f(x)
|
||||
|
||||
def foo(x):
|
||||
print('foo: {}'.format(x))
|
||||
|
||||
|
||||
foreach([1, 2, 3, 4, 5], foo)
|
||||
foreach([1, 2, 3, 4, 5], print)
|
Loading…
Reference in a new issue