about summary refs log tree commit diff stats
path: root/js/scripting-lang/scratch_tests/test_combinator_solution.txt
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/scratch_tests/test_combinator_solution.txt')
-rw-r--r--js/scripting-lang/scratch_tests/test_combinator_solution.txt22
1 files changed, 22 insertions, 0 deletions
diff --git a/js/scripting-lang/scratch_tests/test_combinator_solution.txt b/js/scripting-lang/scratch_tests/test_combinator_solution.txt
new file mode 100644
index 0000000..cc806a0
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_combinator_solution.txt
@@ -0,0 +1,22 @@
+/* Test our combinator solution */
+x : 5;
+y : (x);           /* Should be identity(x) = 5 */
+z : (x - 1);       /* Should be subtract(x, 1) = 4 */
+f : x -> x * 2;
+result1 : f x;     /* Should be apply(f, x) = 10 */
+result2 : (f x);   /* Should be identity(apply(f, x)) = 10 */
+
+/* Test recursive function */
+factorial : n -> 
+  when n is
+    0 then 1
+    _ then n * (factorial (n - 1));
+
+result3 : factorial 3;
+
+/* Print results */
+..out y;
+..out z;
+..out result1;
+..out result2;
+..out result3; 
\ No newline at end of file