All pastes #813987 Raw Edit

k4st

public text v1 · immutable
·published 2007-12-12 22:31 UTC
rendered paste body

/* very complicated idea, might not be possible! */
any f:function, g:function:
	(f+g)(...) => apply(f, args) + apply(g, args) /* addition */
	(f-g)(...) => f(x) - g(x) /* subtraction */
	(f.g)(...) => f(g(x)) /* composition */
;

/* syntax for quickly typed simple functions and more involved functions by
   returning a language construct 
 */

simple(x) => x+2

complex(x) => do:
	x = x+2
	return x
;

many_args(...) => do:
	return args; /* array of arguments */
;

/* example of an iterator */
iterator(some_array) => for elem in some_array:
	yield elem;
;