I\'m trying to come up with an Rx Builder to use Reactive Extension within the F# Computation Expression syntax. How do I fix it so that it doesnt blow the stack? Like the Seq e
If we remove the syntactic sugar from this computation expression (aka Monad) we will have:
let rec g x = Observable.Defer (fun () -> Observable.merge(Observable.Return x, g (x + 1) )
Or in C#:
public static IObservable g(int x)
{
return Observable.Defer(() =>
{
return Observable.Merge(Observable.Return(x), g(x + 1));
});
}
Which is definitely not tail recursive. I think if you can make it tail recursive then it would probably solve your problem