Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,18 @@
|
|||
def square(n):
|
||||
return n * n
|
||||
|
||||
numbers = [1, 3, 5, 7]
|
||||
|
||||
squares1 = [square(n) for n in numbers] # list comprehension
|
||||
|
||||
squares2a = map(square, numbers) # functional form
|
||||
|
||||
squares2b = map(lambda x: x*x, numbers) # functional form with `lambda`
|
||||
|
||||
squares3 = [n * n for n in numbers] # no need for a function,
|
||||
# anonymous or otherwise
|
||||
|
||||
isquares1 = (n * n for n in numbers) # iterator, lazy
|
||||
|
||||
import itertools
|
||||
isquares2 = itertools.imap(square, numbers) # iterator, lazy
|
||||
|
|
@ -0,0 +1 @@
|
|||
print " ".join(str(n * n) for n in range(10))
|
||||
|
|
@ -0,0 +1 @@
|
|||
print " ".join(map(str, map(square, range(10))))
|
||||
|
|
@ -0,0 +1 @@
|
|||
0 1 4 9 16 25 36 49 64 81
|
||||
Loading…
Add table
Add a link
Reference in a new issue