# Rubyにて # 外部イテレータとして使う i = [1,2,3].to_enum # => #<Enumerator: [1, 2, 3]:each> i.next # => 1 i.next # => 2 i.next # => 3 i.next rescue $! # => #<StopIteration: iteration reached an end> # 循環リスト i = [1,2].cycle # => #<Enumerator: [1, 2]:cycle> i.next # => 1 i.next # => 2 i.next # => 1 i.next # => 2 ;;; リストからなるイテレータ (let ((iter (iterator:list '(1 2 3)))) (iterator:next iter) ; => 1 (iterator:next it
![iterator.el : Emacs Lispで外部イテレータを実現する](https://cdn-ak-scissors.b.st-hatena.com/image/square/a3c046ab7bfe74ed8ae2defb7fd7fd66affc6210/height=288;version=1;width=512/http%3A%2F%2Femacs.rubikitch.com%2Fwp-content%2Fuploads%2F2016%2F09%2Femacs.jpg)