=== Program === // copied from K: tests/diverse/higher-order.simple var x, a[10]; function incx() { ++x; } function zero() { return 0; } function id(x) { return x; } function double(x) { return 2*x; } function hoincx() { return incx; } function hozero() { return zero; } function hoid() { return id; } function hodouble() { return double; } function app0(f) { f(); } function app1(f) { return f(); } function app2(f,x) { return f(x); } function map(f,x) { for (var i = 0; i <= sizeOf(x) - 1; ++i) { x[i] = app2(f,x[i]); } } function printall() { print("x = ",x, "; a[] = "); for (var i = 0; i <= sizeOf(a) - 1; ++i) { print(a[i], " "); } print("\n"); } function main() { x = 0; var i; for (var i=0; i <= sizeOf(a) - 1; ++i) { a[i]=i; } printall(); hoincx()(); print(x," ", hozero()()," ", hoid()(7)," ", hodouble()(7),"\n"); id(hoincx())(); print(x," ", id(hozero())()," ", id(hoid())(7)," ", id(hodouble())(7),"\n"); app0(id(hoincx())); print(x," ", app1(id(hozero()))," ", app2(id(hoid()),7)," ", app2(id(hodouble()),7),"\n"); map(double,a); printall(); } === Output === Result: null-value Output Entity: standard-out "x = ",0,"; a[] = ",0," ",1," ",2," ",3," ",4," ",5," ",6," ",7," ",8," ",9," ","\n",1," ",0," ",7," ",14,"\n",2," ",0," ",7," ",14,"\n",3," ",0," ",7," ",14,"\n","x = ",3,"; a[] = ",0," ",2," ",4," ",6," ",8," ",10," ",12," ",14," ",16," ",18," ","\n"