目次

cycle

 
// return type : Iterator
Iterator::cycle : method();

Description

イテレートする要素がなくなったら最初からイテレートしなおすイテレータを返します。

Example

0,1,2,0,1,2,… となるイテレータのうち、最初の10個を出力する

C++

Xtal

(0..2).cycle.take(10){
    it.p;
}

Output

0
1
2
0
1
2
0
1
2
0