6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

lambdaを使う例

Last updated at Posted at 2013-08-27

lambdaって便利っぽいけどイマイチ使いどころが分からんばい
と思ってた駄プログラマだけど、この使い方は結構便利かなと思ったのでメモ。

Pythonの無名関数(lambda)の使い方 - Life with Python

# リストを適当に定義
l = [ "abcde", "bcdef", "cdefg" ]

import re
# 一致するデータだけ取り出す
print filter( lambda x: re.search("bc", x), l )
# ['abcde', 'bcdef']

mapとかでもこんな感じで応用可能。これはベネ。

6
5
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?