user2431438
user2431438

Reputation: 307

F# check if 2 maps are identical

Is there any short way to check if 2 maps are identical?

For example

map [("a", 10)]
map [("a", 10)]

-> identical

map [("b", 10)]
map [("b", 11)]

-> not identical

Upvotes: 0

Views: 166

Answers (2)

Daniel Fabian
Daniel Fabian

Reputation: 3838

F# uses structural comparison in most cases and there in particular your comparision would be true.

Upvotes: 1

John Palmer
John Palmer

Reputation: 25516

The default = appears to work

>   Map.ofArray [| (1,"A");(2,"B") |] =   Map.ofArray [| (1,"A");(2,"B") |];;
val it : bool = true
>   Map.ofArray [| (1,"A");(2,"B") |] =   Map.ofArray [| (1,"A");(3,"B") |];;
val it : bool = false

Upvotes: 5

Related Questions