LoginSignup
2
2

More than 5 years have passed since last update.

Qiitaに初投稿してみる

Last updated at Posted at 2016-02-13

リストの中身が全て同じか調べる(バグまみれ)

reduceを使ってみる。

reduce(lambda x, y: x == y, items)

あ、空リストだと怒られるから初期値設定しないとだめか...

print reduce(lambda x, y: x == y, [])
# TypeError: reduce() of empty sequence with no initial value

print reduce(lambda x, y: x == y, [], True)

...isが関数だったらもっとスッキリするんだけどなー

追記
ちょっとの間に指摘をいただけました。
というかちょっと考えたらこれ色々だめじゃん...orz

試しに投稿してみよーっと思ったら初っぱなから間違えたー
戒めとしてとっておこう...

追記
全く閲覧されないと思っていたらばしばし指摘をいただいてしまいました、Qiitaすげぇ...
あまりにもタイトルと内容が乖離してしまっているので、この記事のタイトルは変更して新たな記事を作成しました。

2
2
7

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
2
2