Base case not getting picked up in my F# function

This function is supposed to just return the index of a list. That part works. However when a element is not in a list it must return -1. For some reason it does not return -1. let rec search f list = match list with | head::tail -> if f head then 0 else 1… Read More Base case not getting picked up in my F# function

How to unsubscribe an event from inside the event handler?

My code subscribes to an event and it needs to unsubscribe (Dispose) once the event has been handled. However this looks like a chicken-egg problem. Using rec doesn’t work and I cannot find how to do it. It there any well-konwn pattern to bypass this limitation? let process = new Process() let exitSubscription = process.Exited.Subscribe… Read More How to unsubscribe an event from inside the event handler?

Function that returns another function executes the body of outer function on every call of the returned function

It is actually pretty unxpected to me but consider this snippet in F#: let f x = printfn $"{x}" fun x’ -> x’ let y<‘t> = f 1 //> val y<‘t> : (obj -> obj) y 2 //> //1 //val it: obj = 2 what I would expect is that it will print "1" only… Read More Function that returns another function executes the body of outer function on every call of the returned function