{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/15","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/15/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/15/events","html_url":"https://github.com/dotnet/roslyn/issues/15","id":54580493,"number":15,"title":"Feature Request: Recursive Iterators (non-quadratic)","user":{"login":"AdamSpeight2008","id":900107,"avatar_url":"https://avatars.githubusercontent.com/u/900107?v=3","gravatar_id":"","url":"https://api.github.com/users/AdamSpeight2008","html_url":"https://github.com/AdamSpeight2008","followers_url":"https://api.github.com/users/AdamSpeight2008/followers","following_url":"https://api.github.com/users/AdamSpeight2008/following{/other_user}","gists_url":"https://api.github.com/users/AdamSpeight2008/gists{/gist_id}","starred_url":"https://api.github.com/users/AdamSpeight2008/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AdamSpeight2008/subscriptions","organizations_url":"https://api.github.com/users/AdamSpeight2008/orgs","repos_url":"https://api.github.com/users/AdamSpeight2008/repos","events_url":"https://api.github.com/users/AdamSpeight2008/events{/privacy}","received_events_url":"https://api.github.com/users/AdamSpeight2008/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/roslyn/labels/1%20-%20Planning","name":"1 - Planning","color":"cccccc"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-Language%20Design","name":"Area-Language Design","color":"5319e7"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Feature%20Request","name":"Feature Request","color":"fc2929"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Language-C%23","name":"Language-C#","color":"207de5"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Language-VB","name":"Language-VB","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-01-16T14:25:53Z","updated_at":"2016-01-12T20:38:35Z","closed_at":null,"body":"Current if you want write a recursive based iterator function.\r\n```\r\nIterator Function TreeWalk(Of T) ( curr As BinaryNode(Of T)) : IEnumerable(Of BinaryNode(Of T))\r\n  If curr Is Nothing Then Return Enumerable.Empty(Of BinaryNode(Of T))\r\n  ForEach node In TreeWalk( curr.Left )\r\n    Yield node\r\n  Next\r\n  Yield curr\r\n  ForEach node In TreeWalk( curr.Righ )\r\n    Yield node\r\n  Next\r\nEnd Function\r\n```\r\nit ends up being Quadratic runtime \r\n\r\nIf I could express the Iterator / Yielder as a parameter I could linearise the runtime.\r\n```\r\nIteration Function TreeWalk( n : BinaryNode, iterator As ?? ) : IEnumerable(Of T)\r\n  If n Is Nothing Then Exit Functon\r\n  If n.Left IsNot Nothing Then TreeWalk(n.Left, Iterator)\r\n  Yield n.Value on Iterator\r\n  If n.Righ IsNot Nothing Then TreeWalk(n.Righ, Iterator)\r\nEnd Function\r\n```"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/171047023","html_url":"https://github.com/dotnet/roslyn/issues/15#issuecomment-171047023","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/15","id":171047023,"user":{"login":"AlexRadch","id":6407980,"avatar_url":"https://avatars.githubusercontent.com/u/6407980?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexRadch","html_url":"https://github.com/AlexRadch","followers_url":"https://api.github.com/users/AlexRadch/followers","following_url":"https://api.github.com/users/AlexRadch/following{/other_user}","gists_url":"https://api.github.com/users/AlexRadch/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexRadch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexRadch/subscriptions","organizations_url":"https://api.github.com/users/AlexRadch/orgs","repos_url":"https://api.github.com/users/AlexRadch/repos","events_url":"https://api.github.com/users/AlexRadch/events{/privacy}","received_events_url":"https://api.github.com/users/AlexRadch/received_events","type":"User","site_admin":false},"created_at":"2016-01-12T20:38:35Z","updated_at":"2016-01-12T20:38:35Z","body":"I think it may be more comfortable to enable yield return of IEnumerable as syntax sugar for loop with yield return.\r\n\r\n```cs\r\nIEnumerable<BinaryNode<T>> TreeWalk<T>(BinaryNode<T> curr)\r\n{\r\n    If (curr == null)\r\n        yield break;\r\n    yield return TreeWalk(curr.Left); // Syntax  sugar for loop with yield return\r\n    yield return curr;\r\n    yield return TreeWalk(curr.Rigth); // // Syntax  sugar for loop with yield return\r\n}\r\n```"}}