about summary refs log tree commit diff stats
path: root/js/scripting-lang/scratch_tests/test_each_solution.txt
blob: f8dbf902bb0ec73e9ec682ae8dc0afc3466ff47b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;