diff --git a/28.nix b/28.nix new file mode 100644 index 0000000..8c9a2f1 --- /dev/null +++ b/28.nix @@ -0,0 +1,11 @@ +with import { }; +let + list = ["a" "b" "a" "c" "d" "a"]; + countA = lib.fold (x: y: if x != "a" then y else y + 1) 0; +in +rec { + example = lib.fold (x: y: x + y) "" ["a" "b" "c"]; #is "abc" + result = countA list; #should be 3 +} + +# fold f z [x_1 x_2 ... x_n] == f x_1 (f x_2 ... (f x_n z)) \ No newline at end of file