/* Test function composition implementation */ f : x -> x * 2; g : x -> x + 1; h : x -> x * x; /* Test 1: Basic composition */ result1 : f via g 5; /* Should be compose(f, g)(5) = f(g(5)) = f(6) = 12 */ /* Test 2: Multiple composition */ result2 : f via g via h 3; /* Should be compose(f, compose(g, h))(3) = f(g(h(3))) = f(g(9)) = f(10) = 20 */ /* Test 3: Function references */ result3 : @f; /* Should return the function f */ /* Test 4: Function reference in composition */ result4 : @f via @g 5; /* Should be compose(f, g)(5) = 12 */ /* Test 5: Pipe function */ result5 : pipe(f, g) 5; /* Should be g(f(5)) = g(10) = 11 */ /* Test 6: Backward compatibility */ result6 : f 5; /* Should still work: apply(f, 5) = 10 */ result7 : f g 5; /* Should still work: apply(apply(f, g), 5) - may fail as expected */ /* Test 7: Natural language examples */ data : {1, 2, 3, 4, 5}; result8 : data via filter via map via reduce; /* Pipeline example */ /* Test 8: Enhanced compose with multiple functions */ result9 : compose(f, g, h) 2; /* Should be f(g(h(2))) = f(g(4)) = f(5) = 10 */ /* Test 9: Enhanced pipe with multiple functions */ result10 : pipe(h, g, f) 2; /* Should be f(g(h(2))) = f(g(4)) = f(5) = 10 */