From 6aabf9b7dd1d7522ba574225992537ea57c9aadb Mon Sep 17 00:00:00 2001 From: Billingsly Wetherfordshire Date: Sat, 4 May 2013 03:15:22 -0500 Subject: [PATCH 1/3] add hashing for seqs --- lib/pure/hashes.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pure/hashes.nim b/lib/pure/hashes.nim index cf0777ff7d..0e9e3600df 100644 --- a/lib/pure/hashes.nim +++ b/lib/pure/hashes.nim @@ -126,3 +126,6 @@ proc hash*(x: float): THash {.inline.} = var y = x + 1.0 result = cast[ptr THash](addr(y))[] +proc hash*[A](x: seq[A]): THash = + for it in items(x): result = result !& hash(it) + result = !$result From e662c973efdc1c9bcab6543713a742e6f54b34d3 Mon Sep 17 00:00:00 2001 From: Billingsly Wetherfordshire Date: Sat, 4 May 2013 04:39:21 -0500 Subject: [PATCH 2/3] Change hash[T](seq[A]) to take varargs[A] --- lib/pure/hashes.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pure/hashes.nim b/lib/pure/hashes.nim index 0e9e3600df..92f273b153 100644 --- a/lib/pure/hashes.nim +++ b/lib/pure/hashes.nim @@ -126,6 +126,6 @@ proc hash*(x: float): THash {.inline.} = var y = x + 1.0 result = cast[ptr THash](addr(y))[] -proc hash*[A](x: seq[A]): THash = +proc hash*[A](x: varargs[A]): THash = for it in items(x): result = result !& hash(it) result = !$result From cc887bf66e3df40babd29e89e45c71e2e3cca079 Mon Sep 17 00:00:00 2001 From: Billingsly Wetherfordshire Date: Sat, 4 May 2013 19:26:02 -0500 Subject: [PATCH 3/3] Change varargs[T] to openarray[T] --- lib/pure/hashes.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pure/hashes.nim b/lib/pure/hashes.nim index 92f273b153..8a3135f89c 100644 --- a/lib/pure/hashes.nim +++ b/lib/pure/hashes.nim @@ -126,6 +126,6 @@ proc hash*(x: float): THash {.inline.} = var y = x + 1.0 result = cast[ptr THash](addr(y))[] -proc hash*[A](x: varargs[A]): THash = +proc hash*[A](x: openarray[A]): THash = for it in items(x): result = result !& hash(it) result = !$result