All pastes #811482 Raw Edit

k4st

public text v1 · immutable
·published 2007-12-10 23:29 UTC
rendered paste body
-------------------------------------

functions/scopes:

a = {
	...
}

-------------------------------------

lambda-scopes:

{
	...
}

-------------------------------------

self/calling scopes:

{
	...
}()

(a = {
	// a can also be re-used
	...
})()

-------------------------------------

recursion with scopes:

a = {
	
	if(true) {
		a()
	}
}

-------------------------------------

while loops:

(while = {
	do = {
		...
		while()
	}
	
	if(condition) {
		do()
	}
})()

-------------------------------------

do-while loops:

(do = {
	...
	
	if(condition) {
		do()
	}
})()

-------------------------------------

scope with arguments (classic function):

fac = (num){
	if(num > 0)
		num*fac(num-1)
	else
		1
}

-------------------------------------

currying:

adder = (a){
	(b){
		a+b
	}
}
add2 = adder(2)
four = add2(2)