Skip to content

Instantly share code, notes, and snippets.

@mausch
Last active December 15, 2015 09:49
Show Gist options
  • Save mausch/5241729 to your computer and use it in GitHub Desktop.
Save mausch/5241729 to your computer and use it in GitHub Desktop.
Anonymous iterators in C# with Ix
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"
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"
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"
@mausch
Copy link
Author

mausch commented Mar 26, 2013

Created a new issue: http://rx.codeplex.com/workitem/20 , going to sleep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment