"함수 map()"의 두 판 사이의 차이

(새 문서: ;map ==Python== category: Python ;Python 3 <source lang='Python'> numbers = [1, 2, 3, 4, 5, 6] print( list(map(lambda x: x * 2 - 1, numbers)) ) # [1, 3, 5, 7, 9, 11] </source> =...)
 
8번째 줄: 8번째 줄:
print( list(map(lambda x: x * 2 - 1, numbers)) )
print( list(map(lambda x: x * 2 - 1, numbers)) )
# [1, 3, 5, 7, 9, 11]
# [1, 3, 5, 7, 9, 11]
</source>
<source lang='Python'>
numbers = [1, 2, 3, 4, 5, 6]
print( [x * 2 for x in numbers] )
# [2, 4, 6, 8, 10, 12]
</source>
</source>



2014년 8월 22일 (금) 09:29 판

map

1 Python

Python 3
numbers = [1, 2, 3, 4, 5, 6]
print( list(map(lambda x: x * 2 - 1, numbers)) )
# [1, 3, 5, 7, 9, 11]
numbers = [1, 2, 3, 4, 5, 6]
print( [x * 2 for x in numbers] )
# [2, 4, 6, 8, 10, 12]

2 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}