Reputation: 1163
How would I remove an item from an array, provided that it does not have equality?
For example, for an item with equality, I could do the following:
Array.filter (fun x -> x <> itemToRemove) array
Unfortunately, that does not work since in my case, I have a tuple in which the third item is a curried function (to which I provide the last argument later), and this does not have equality.
EDIT:
Here is the exact example I am having problems with:
let arrayWithoutReq = Array.filter (fun (req:(string * Port<'a> * ('a -> bool) option * int * DateTime)) -> req <> fullfilableReq) (originalFifoRequests.toArray())
Upvotes: 1
Views: 68
Reputation: 21742
Since you are talking about identity comparison, use the build in reference comparison
let arrayWithoutReq =
originalFifoRequests
|> Seq.filter (fun req ->
Object.ReferenceEquals(req, fullfilableReq) |> not)
|> Seq.toArry
Upvotes: 4