-
Notifications
You must be signed in to change notification settings - Fork 89
Using Structural Hashing
CodingUnit edited this page Feb 6, 2012
·
3 revisions
- Category: Equality, Comparison and Hashing
- Description: This sample shows the results of some simple structural hashing operations.
- Code:
using System.Console;
def show[T](a : T)
{
WriteLine($"hash of $a : $(a.GetHashCode())")
}
show(1);
show(2);
show("1");
show("2");
show("abb");
show("aBc"); // case-sensitive
show(None());
show(Some(1));
show(Some(0));
show([1, 2, 3]);
show([1, 2, 3, 4, 5, 6, 7, 8]);
show([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
show([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
- Execution Result:
hash of 1 : 1
hash of 2 : 2
hash of 1 : 372029325
hash of 2 : 372029328
hash of abb : 1099313833
hash of aBc : -325607606
hash of None : 0
hash of Some (1) : 1
hash of Some (0) : 0
hash of [1, 2, 3] : -1379947063
hash of [1, 2, 3, 4, 5, 6, 7, 8] : 1079935765
hash of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] : -1406969459
hash of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] : -1542895889
[Copyright ©](Terms of use, legal notice)