Last active
December 15, 2015 09:49
-
-
Save mausch/5241729 to your computer and use it in GitHub Desktop.
Anonymous iterators in C# with Ix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hello = ""; | |
var enumerable = | |
EnumerableEx.Create<int>(async Yield => { | |
await Yield.Return(100); | |
await Yield.Return(200); | |
hello = "hello world"; | |
await Yield.Return(300); | |
}); | |
Console.WriteLine(enumerable.ElementAt(1)); // 200 | |
Console.WriteLine(hello); // empty | |
Console.WriteLine(enumerable.ElementAt(2)); // 300 | |
Console.WriteLine(hello); // "hello world" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mutable hello = "" | |
let enumerable = | |
seq { | |
yield 100 | |
yield 200 | |
hello <- "hello world" | |
yield 300 | |
} | |
printfn "%d" (enumerable.ElementAt 1) // 200 | |
printfn "%s" hello // empty | |
printfn "%d" (enumerable.ElementAt 2) // 300 | |
printfn "%s" hello // "hello world" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim hello = "" | |
Dim enumerable = | |
Iterator Function() | |
Yield 100 | |
Yield 200 | |
hello = "hello world" | |
Yield 300 | |
End Function | |
Console.WriteLine(enumerable().ElementAt(1)) ' 200 | |
Console.WriteLine(hello) ' empty | |
Console.WriteLine(enumerable().ElementAt(2)) ' 300 | |
Console.WriteLine(hello) ' "hello world" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Created a new issue: http://rx.codeplex.com/workitem/20 , going to sleep