about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/lang/eval-okay-flatten.exp1
-rw-r--r--tests/lang/eval-okay-flatten.nix19
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/lang/eval-okay-flatten.exp b/tests/lang/eval-okay-flatten.exp
new file mode 100644
index 000000000000..e76d25de12b0
--- /dev/null
+++ b/tests/lang/eval-okay-flatten.exp
@@ -0,0 +1 @@
+Str("1234567")
diff --git a/tests/lang/eval-okay-flatten.nix b/tests/lang/eval-okay-flatten.nix
new file mode 100644
index 000000000000..2019263b8297
--- /dev/null
+++ b/tests/lang/eval-okay-flatten.nix
@@ -0,0 +1,19 @@
+let {
+
+  fold = op: nul: list:
+    if list == []
+    then nul
+    else op (builtins.head list) (fold op nul (builtins.tail list));
+
+  concat =
+    fold (x: y: x + y) "";
+    
+  flatten = x:
+    if builtins.isList x
+    then fold (x: y: (flatten x) ++ y) [] x
+    else [x];
+
+  l = ["1" "2" ["3" ["4"] ["5" "6"]] "7"];
+
+  body = concat (flatten l);
+}