{"action":"created","comment":{"url":"https://api.github.com/repos/munificent/wren/pulls/comments/27482379","id":27482379,"diff_hunk":"@@ -0,0 +1,45 @@\n+// Infinite iterator demonstrating that Sequence.map is not eager\n+class FibIterator {\n+  new {\n+    _current = 0\n+    _next = 1\n+  }\n+\n+  iterate {\n+    var sum = _current + _next\n+    _current = _next\n+    _next = sum\n+  }\n+\n+  value { _current }\n+}\n+\n+class Fib is Sequence {\n+  iterate(iterator) {\n+    if (iterator == null) return new FibIterator\n+    iterator.iterate\n+    return iterator\n+  }\n+\n+  iteratorValue(iterator) { iterator.value }\n+}\n+\n+var squareFib = (new Fib).map {|fib| fib * fib }\n+var iterator = null","path":"test/core/sequence/map.wren","position":28,"original_position":28,"commit_id":"20ece8f79d41a43f3b79c78823103c7c7ac27483","original_commit_id":"20ece8f79d41a43f3b79c78823103c7c7ac27483","user":{"login":"munificent","id":46275,"avatar_url":"https://avatars.githubusercontent.com/u/46275?v=3","gravatar_id":"","url":"https://api.github.com/users/munificent","html_url":"https://github.com/munificent","followers_url":"https://api.github.com/users/munificent/followers","following_url":"https://api.github.com/users/munificent/following{/other_user}","gists_url":"https://api.github.com/users/munificent/gists{/gist_id}","starred_url":"https://api.github.com/users/munificent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/munificent/subscriptions","organizations_url":"https://api.github.com/users/munificent/orgs","repos_url":"https://api.github.com/users/munificent/repos","events_url":"https://api.github.com/users/munificent/events{/privacy}","received_events_url":"https://api.github.com/users/munificent/received_events","type":"User","site_admin":false},"body":"Can you add a line here:\r\n\r\n```dart\r\nIO.print(squareFib is Sequence) // expect: true\r\n```\r\n\r\nAnd do the same thing for `where()` as well.\r\n","created_at":"2015-03-31T14:15:04Z","updated_at":"2015-03-31T14:15:04Z","html_url":"https://github.com/munificent/wren/pull/243#discussion_r27482379","pull_request_url":"https://api.github.com/repos/munificent/wren/pulls/243","_links":{"self":{"href":"https://api.github.com/repos/munificent/wren/pulls/comments/27482379"},"html":{"href":"https://github.com/munificent/wren/pull/243#discussion_r27482379"},"pull_request":{"href":"https://api.github.com/repos/munificent/wren/pulls/243"}}},"pull_request":{"url":"https://api.github.com/repos/munificent/wren/pulls/243","id":32172006,"html_url":"https://github.com/munificent/wren/pull/243","diff_url":"https://github.com/munificent/wren/pull/243.diff","patch_url":"https://github.com/munificent/wren/pull/243.patch","issue_url":"https://api.github.com/repos/munificent/wren/issues/243","number":243,"state":"open","locked":false,"title":"Use deferred execution for Sequence.map and Sequence.where","user":{"login":"bjorn","id":531764,"avatar_url":"https://avatars.githubusercontent.com/u/531764?v=3","gravatar_id":"","url":"https://api.github.com/users/bjorn","html_url":"https://github.com/bjorn","followers_url":"https://api.github.com/users/bjorn/followers","following_url":"https://api.github.com/users/bjorn/following{/other_user}","gists_url":"https://api.github.com/users/bjorn/gists{/gist_id}","starred_url":"https://api.github.com/users/bjorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjorn/subscriptions","organizations_url":"https://api.github.com/users/bjorn/orgs","repos_url":"https://api.github.com/users/bjorn/repos","events_url":"https://api.github.com/users/bjorn/events{/privacy}","received_events_url":"https://api.github.com/users/bjorn/received_events","type":"User","site_admin":false},"body":"The methods `Sequence.map` and `Sequence.where` are now implemented using deferred execution. They return an instance of a new Sequence-derived class that performs the operation while iterating. This has three main advantages:\r\n\r\n* It can be computationally cheaper when not the whole sequence is  iterated.\r\n* It consumes less memory since it does not store the result in a newly allocated list.\r\n* They can work on infinite sequences.\r\n\r\nSome disadvantages are:\r\n\r\n* Iterating the returned iterator will be slightly slower due to the added indirection.\r\n* You should be aware that modifications made to the original sequence will affect the returned sequence.\r\n* If you need the result in a list, you now need to call `Sequence.list` on the result.\r\n\r\nFor correct behavior of the basic Wren example, this change depends on #241 to avoid usage of the lazy `Sequence.map` there.","created_at":"2015-03-28T21:54:17Z","updated_at":"2015-03-31T14:15:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15d4dc78d5a6b258a147762bef8e1b80a76991b3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/munificent/wren/pulls/243/commits","review_comments_url":"https://api.github.com/repos/munificent/wren/pulls/243/comments","review_comment_url":"https://api.github.com/repos/munificent/wren/pulls/comments{/number}","comments_url":"https://api.github.com/repos/munificent/wren/issues/243/comments","statuses_url":"https://api.github.com/repos/munificent/wren/statuses/20ece8f79d41a43f3b79c78823103c7c7ac27483","head":{"label":"bjorn:deferred_execution","ref":"deferred_execution","sha":"20ece8f79d41a43f3b79c78823103c7c7ac27483","user":{"login":"bjorn","id":531764,"avatar_url":"https://avatars.githubusercontent.com/u/531764?v=3","gravatar_id":"","url":"https://api.github.com/users/bjorn","html_url":"https://github.com/bjorn","followers_url":"https://api.github.com/users/bjorn/followers","following_url":"https://api.github.com/users/bjorn/following{/other_user}","gists_url":"https://api.github.com/users/bjorn/gists{/gist_id}","starred_url":"https://api.github.com/users/bjorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjorn/subscriptions","organizations_url":"https://api.github.com/users/bjorn/orgs","repos_url":"https://api.github.com/users/bjorn/repos","events_url":"https://api.github.com/users/bjorn/events{/privacy}","received_events_url":"https://api.github.com/users/bjorn/received_events","type":"User","site_admin":false},"repo":{"id":31474121,"name":"wren","full_name":"bjorn/wren","owner":{"login":"bjorn","id":531764,"avatar_url":"https://avatars.githubusercontent.com/u/531764?v=3","gravatar_id":"","url":"https://api.github.com/users/bjorn","html_url":"https://github.com/bjorn","followers_url":"https://api.github.com/users/bjorn/followers","following_url":"https://api.github.com/users/bjorn/following{/other_user}","gists_url":"https://api.github.com/users/bjorn/gists{/gist_id}","starred_url":"https://api.github.com/users/bjorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjorn/subscriptions","organizations_url":"https://api.github.com/users/bjorn/orgs","repos_url":"https://api.github.com/users/bjorn/repos","events_url":"https://api.github.com/users/bjorn/events{/privacy}","received_events_url":"https://api.github.com/users/bjorn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bjorn/wren","description":"The Wren Programming Language","fork":true,"url":"https://api.github.com/repos/bjorn/wren","forks_url":"https://api.github.com/repos/bjorn/wren/forks","keys_url":"https://api.github.com/repos/bjorn/wren/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bjorn/wren/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bjorn/wren/teams","hooks_url":"https://api.github.com/repos/bjorn/wren/hooks","issue_events_url":"https://api.github.com/repos/bjorn/wren/issues/events{/number}","events_url":"https://api.github.com/repos/bjorn/wren/events","assignees_url":"https://api.github.com/repos/bjorn/wren/assignees{/user}","branches_url":"https://api.github.com/repos/bjorn/wren/branches{/branch}","tags_url":"https://api.github.com/repos/bjorn/wren/tags","blobs_url":"https://api.github.com/repos/bjorn/wren/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bjorn/wren/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bjorn/wren/git/refs{/sha}","trees_url":"https://api.github.com/repos/bjorn/wren/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bjorn/wren/statuses/{sha}","languages_url":"https://api.github.com/repos/bjorn/wren/languages","stargazers_url":"https://api.github.com/repos/bjorn/wren/stargazers","contributors_url":"https://api.github.com/repos/bjorn/wren/contributors","subscribers_url":"https://api.github.com/repos/bjorn/wren/subscribers","subscription_url":"https://api.github.com/repos/bjorn/wren/subscription","commits_url":"https://api.github.com/repos/bjorn/wren/commits{/sha}","git_commits_url":"https://api.github.com/repos/bjorn/wren/git/commits{/sha}","comments_url":"https://api.github.com/repos/bjorn/wren/comments{/number}","issue_comment_url":"https://api.github.com/repos/bjorn/wren/issues/comments{/number}","contents_url":"https://api.github.com/repos/bjorn/wren/contents/{+path}","compare_url":"https://api.github.com/repos/bjorn/wren/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bjorn/wren/merges","archive_url":"https://api.github.com/repos/bjorn/wren/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bjorn/wren/downloads","issues_url":"https://api.github.com/repos/bjorn/wren/issues{/number}","pulls_url":"https://api.github.com/repos/bjorn/wren/pulls{/number}","milestones_url":"https://api.github.com/repos/bjorn/wren/milestones{/number}","notifications_url":"https://api.github.com/repos/bjorn/wren/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bjorn/wren/labels{/name}","releases_url":"https://api.github.com/repos/bjorn/wren/releases{/id}","created_at":"2015-02-28T19:43:01Z","updated_at":"2015-03-25T23:02:26Z","pushed_at":"2015-03-28T21:52:09Z","git_url":"git://github.com/bjorn/wren.git","ssh_url":"git@github.com:bjorn/wren.git","clone_url":"https://github.com/bjorn/wren.git","svn_url":"https://github.com/bjorn/wren","homepage":"http://munificent.github.io/wren/","size":3611,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"munificent:master","ref":"master","sha":"37e1e8fe77005091bbfe9ea281af4a6565100c79","user":{"login":"munificent","id":46275,"avatar_url":"https://avatars.githubusercontent.com/u/46275?v=3","gravatar_id":"","url":"https://api.github.com/users/munificent","html_url":"https://github.com/munificent","followers_url":"https://api.github.com/users/munificent/followers","following_url":"https://api.github.com/users/munificent/following{/other_user}","gists_url":"https://api.github.com/users/munificent/gists{/gist_id}","starred_url":"https://api.github.com/users/munificent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/munificent/subscriptions","organizations_url":"https://api.github.com/users/munificent/orgs","repos_url":"https://api.github.com/users/munificent/repos","events_url":"https://api.github.com/users/munificent/events{/privacy}","received_events_url":"https://api.github.com/users/munificent/received_events","type":"User","site_admin":false},"repo":{"id":14509809,"name":"wren","full_name":"munificent/wren","owner":{"login":"munificent","id":46275,"avatar_url":"https://avatars.githubusercontent.com/u/46275?v=3","gravatar_id":"","url":"https://api.github.com/users/munificent","html_url":"https://github.com/munificent","followers_url":"https://api.github.com/users/munificent/followers","following_url":"https://api.github.com/users/munificent/following{/other_user}","gists_url":"https://api.github.com/users/munificent/gists{/gist_id}","starred_url":"https://api.github.com/users/munificent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/munificent/subscriptions","organizations_url":"https://api.github.com/users/munificent/orgs","repos_url":"https://api.github.com/users/munificent/repos","events_url":"https://api.github.com/users/munificent/events{/privacy}","received_events_url":"https://api.github.com/users/munificent/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/munificent/wren","description":"The Wren Programming Language","fork":false,"url":"https://api.github.com/repos/munificent/wren","forks_url":"https://api.github.com/repos/munificent/wren/forks","keys_url":"https://api.github.com/repos/munificent/wren/keys{/key_id}","collaborators_url":"https://api.github.com/repos/munificent/wren/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/munificent/wren/teams","hooks_url":"https://api.github.com/repos/munificent/wren/hooks","issue_events_url":"https://api.github.com/repos/munificent/wren/issues/events{/number}","events_url":"https://api.github.com/repos/munificent/wren/events","assignees_url":"https://api.github.com/repos/munificent/wren/assignees{/user}","branches_url":"https://api.github.com/repos/munificent/wren/branches{/branch}","tags_url":"https://api.github.com/repos/munificent/wren/tags","blobs_url":"https://api.github.com/repos/munificent/wren/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/munificent/wren/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/munificent/wren/git/refs{/sha}","trees_url":"https://api.github.com/repos/munificent/wren/git/trees{/sha}","statuses_url":"https://api.github.com/repos/munificent/wren/statuses/{sha}","languages_url":"https://api.github.com/repos/munificent/wren/languages","stargazers_url":"https://api.github.com/repos/munificent/wren/stargazers","contributors_url":"https://api.github.com/repos/munificent/wren/contributors","subscribers_url":"https://api.github.com/repos/munificent/wren/subscribers","subscription_url":"https://api.github.com/repos/munificent/wren/subscription","commits_url":"https://api.github.com/repos/munificent/wren/commits{/sha}","git_commits_url":"https://api.github.com/repos/munificent/wren/git/commits{/sha}","comments_url":"https://api.github.com/repos/munificent/wren/comments{/number}","issue_comment_url":"https://api.github.com/repos/munificent/wren/issues/comments{/number}","contents_url":"https://api.github.com/repos/munificent/wren/contents/{+path}","compare_url":"https://api.github.com/repos/munificent/wren/compare/{base}...{head}","merges_url":"https://api.github.com/repos/munificent/wren/merges","archive_url":"https://api.github.com/repos/munificent/wren/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/munificent/wren/downloads","issues_url":"https://api.github.com/repos/munificent/wren/issues{/number}","pulls_url":"https://api.github.com/repos/munificent/wren/pulls{/number}","milestones_url":"https://api.github.com/repos/munificent/wren/milestones{/number}","notifications_url":"https://api.github.com/repos/munificent/wren/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/munificent/wren/labels{/name}","releases_url":"https://api.github.com/repos/munificent/wren/releases{/id}","created_at":"2013-11-19T00:43:45Z","updated_at":"2015-03-30T14:39:43Z","pushed_at":"2015-03-30T14:39:43Z","git_url":"git://github.com/munificent/wren.git","ssh_url":"git@github.com:munificent/wren.git","clone_url":"https://github.com/munificent/wren.git","svn_url":"https://github.com/munificent/wren","homepage":"http://munificent.github.io/wren/","size":6869,"stargazers_count":666,"watchers_count":666,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":59,"mirror_url":null,"open_issues_count":33,"forks":59,"open_issues":33,"watchers":666,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/munificent/wren/pulls/243"},"html":{"href":"https://github.com/munificent/wren/pull/243"},"issue":{"href":"https://api.github.com/repos/munificent/wren/issues/243"},"comments":{"href":"https://api.github.com/repos/munificent/wren/issues/243/comments"},"review_comments":{"href":"https://api.github.com/repos/munificent/wren/pulls/243/comments"},"review_comment":{"href":"https://api.github.com/repos/munificent/wren/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/munificent/wren/pulls/243/commits"},"statuses":{"href":"https://api.github.com/repos/munificent/wren/statuses/20ece8f79d41a43f3b79c78823103c7c7ac27483"}}}}