Pythonのお勉強 Part 27at TECH
Pythonのお勉強 Part 27 - 暇つぶし2ch151:デフォルトの名無しさん
08/06/17 11:33:22
>>148
def collatz(n):
  yield n
  n = n % 2 and 3*n + 1 or n/2

>>> collatz(13).next()
13
>>> f = collatz(13)
>>> f.next()
13
>>> f.next()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration

>>> [x for x in collatz(13)]
[13]

>>149
開始位置ってなんじゃらほい
サンプルとかヒントきぼん


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch