/* Test embedded functions in tables */ // Test 1: Simple embedded function (arrow syntax) calculator : { add: x y -> x + y, multiply: x y -> x * y }; // Test 2: Arrow function syntax calculator2 : { add: x y -> x + y, multiply: x y -> x * y }; // Test 3: When expression in table classifier : { classify: x -> when x is 0 then "zero" 1 then "one" _ then "other" }; // Test 4: Mixed content mixed : { name: "Calculator", version: 1.0, add: x y -> x + y, is_valid: x -> x > 0 }; // Test 5: Nested tables with functions nested : { math: { add: x y -> x + y, subtract: x y -> x - y }, logic: { logical_and: x y -> x and y, logical_or: x y -> x or y } }; // Test 6: Function that returns a table table_factory : { create_point: x y -> {x: x, y: y}, create_range: start end -> {start: start, end: end, length: end - start} }; // Output tests ..out "=== EMBEDDED FUNCTIONS TEST ==="; ..out "Calculator add:"; result1 : calculator.add 5 3; ..out result1; ..out "Calculator2 multiply:"; result2 : calculator2.multiply 4 7; ..out result2; ..out "Classifier:"; class1 : classifier.classify 0; ..out class1; class2 : classifier.classify 5; ..out class2; ..out "Mixed table:"; ..out mixed.name; ..out mixed.version; result3 : mixed.add 10 20; ..out result3; valid : mixed.is_valid 5; ..out valid; ..out "Nested functions:"; nested_add : nested.math.add 15 25; ..out nested_add; nested_logic : nested.logic.logical_and true false; ..out nested_logic; ..out "Table factory:"; point : table_factory.create_point 10 20; ..out point; range : table_factory.create_range 1 10; ..out range;