summary refs log tree commit diff stats
path: root/tests/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stdlib')
-rw-r--r--tests/stdlib/tpermutations.nim17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/stdlib/tpermutations.nim b/tests/stdlib/tpermutations.nim
new file mode 100644
index 000000000..99bc424cd
--- /dev/null
+++ b/tests/stdlib/tpermutations.nim
@@ -0,0 +1,17 @@
+discard """
+  output: '''@[0, 1, 2, 3, 4, 5, 6, 7, 9, 8]
+@[0, 1, 2, 3, 4, 5, 6, 8, 7, 9]
+@[0, 1, 2, 3, 4, 5, 6, 8, 9, 7]
+@[0, 1, 2, 3, 4, 5, 6, 8, 7, 9]
+@[0, 1, 2, 3, 4, 5, 6, 7, 9, 8]
+@[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]'''
+"""
+import algorithm
+
+var v = @[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+for i in 1..3:
+  v.nextPermutation()
+  echo v
+for i in 1..3:
+  v.prevPermutation()
+  echo v