diff options
Diffstat (limited to 'io/myAverage.io')
-rw-r--r-- | io/myAverage.io | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/io/myAverage.io b/io/myAverage.io new file mode 100644 index 0000000..ab85a08 --- /dev/null +++ b/io/myAverage.io @@ -0,0 +1,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 |