diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-08-22 18:31:15 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-08-22 18:31:26 +0200 |
commit | 9c9a7b6520e45cc71f071e82e8306ad276d72258 (patch) | |
tree | d7233d11d8b4f1d05d1078af5702a14839e8f561 /tests/iter | |
parent | 3fc95ce69e787b988f2f47adb035eabf082822ca (diff) | |
download | Nim-9c9a7b6520e45cc71f071e82e8306ad276d72258.tar.gz |
fixes #3221
Diffstat (limited to 'tests/iter')
-rw-r--r-- | tests/iter/tcomplex_openarray.nim | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/iter/tcomplex_openarray.nim b/tests/iter/tcomplex_openarray.nim new file mode 100644 index 000000000..6fc191e90 --- /dev/null +++ b/tests/iter/tcomplex_openarray.nim @@ -0,0 +1,33 @@ + +# bug #3221 + +import algorithm, math, sequtils + + +iterator permutations[T](ys: openarray[T]): seq[T] = + var + d = 1 + c = newSeq[int](ys.len) + xs = newSeq[T](ys.len) + for i, y in ys: xs[i] = y + yield xs + block outer: + while true: + while d > 1: + dec d + c[d] = 0 + while c[d] >= d: + inc d + if d >= ys.len: break outer + let i = if (d and 1) == 1: c[d] else: 0 + swap xs[i], xs[d] + yield xs + inc c[d] + +proc dig_vectors(): void = + var v_nums: seq[int] + v_nums = newSeq[int](1) + for perm in permutations(toSeq(0 .. 1)): + v_nums[0] = 1 + +dig_vectors() |