summaryrefslogtreecommitdiff
path: root/io/myAverage.io
blob: ab85a084f54cf80cc824f4b48ea21b27012b9e85 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
InvalidType := Exception clone

List myAverage := method(
	acc := 0
	self foreach(elm,
		if (elm type == "Number") then (
			acc = acc + elm
		) else (
			InvalidType raise(elm type)
		)
	)
	return (acc/size(self))
)

list(1,2,3) myAverage println