Skip to content

Commit

Permalink
fix for new hashes, refs nim-lang/Nim#13410
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Feb 13, 2020
1 parent 0e61385 commit c4ea1ea
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/itertools.nim
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,11 @@ iterator groupBy*[T](s: openArray[T]): tuple[k: T, v: seq[T]] =
s1.add(x)
for x in groupBy(b):
s2.add(x)
when NimVersion < "1.0.99":
doAssert s1 == @[(k: 1, v: @[1, 1]), (k: 2, v: @[2, 2, 2]),
(k: 5, v: @[5, 5]), (k: 7, v: @[7])]
doAssert s2 == @[(k: 'a', v: @['a', 'a', 'a']), (k: 'b', v: @['b', 'b', 'b']),
(k: 'd', v: @['d']), (k: 'n', v: @['n'])]
else:
doAssert s1 == @[(k: 1, v: @[1, 1]), (k: 7, v: @[7]),
(k: 2, v: @[2, 2, 2]), (k: 5, v: @[5, 5])]
doAssert s2 == @[(k: 'd', v: @['d']), (k: 'a', v: @['a', 'a', 'a']),
(k: 'b', v: @['b', 'b', 'b']), (k: 'n', v: @['n'])]
import algorithm
doAssert s1.sortedByIt(it.k) ==
@[(k: 1, v: @[1, 1]), (k: 2, v: @[2, 2, 2]), (k: 5, v: @[5, 5]), (k: 7, v: @[7])]
doAssert s2.sortedByIt(it.k) ==
@[(k: 'a', v: @['a', 'a', 'a']), (k: 'b', v: @['b', 'b', 'b']), (k: 'd', v: @['d']), (k: 'n', v: @['n'])]

var t = initTable[T, seq[T]]()
for x in s:
Expand Down

0 comments on commit c4ea1ea

Please sign in to comment.