aboutsummaryrefslogtreecommitdiff
path: root/examples/sum.lyn
blob: a4dcf61df65babef2e20c7520465ebcd71159b4c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
syntax for {init cond post body} {
	eval init
	while (eval cond) {
		eval body
		eval post
	}
}

def sum {n} {
	require n int
	let s 0
	for {let i 0} {< i n} {set i (+ i 1)} {
		set s (+ s i)
	}
	return s
}

println (sum 1000000)