diff options
Diffstat (limited to 'js/scripting-lang/scratch_tests/test_each_solution.txt')
-rw-r--r-- | js/scripting-lang/scratch_tests/test_each_solution.txt | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/js/scripting-lang/scratch_tests/test_each_solution.txt b/js/scripting-lang/scratch_tests/test_each_solution.txt new file mode 100644 index 0000000..f8dbf90 --- /dev/null +++ b/js/scripting-lang/scratch_tests/test_each_solution.txt @@ -0,0 +1,27 @@ +/* Test to show correct usage patterns for each */ + +numbers : {1, 2, 3, 4, 5}; +add_ten : x -> x + 10; + +/* For single table operations, use map */ +map_result : map @add_ten numbers; +..out "Map with single table:"; +..out map_result; + +/* For two-argument operations with table and scalar, use each */ +each_result1 : each @add numbers 10; +..out "Each with table and scalar:"; +..out each_result1; + +/* For two-table operations, use each */ +table1 : {a: 1, b: 2, c: 3}; +table2 : {a: 10, b: 20, c: 30}; +each_result2 : each @add table1 table2; +..out "Each with two tables:"; +..out each_result2; + +/* For partial application, use each */ +add_to_ten : each @add 10; +each_result3 : add_to_ten numbers; +..out "Each with partial application:"; +..out each_result3; \ No newline at end of file |