diff options
author | Guillermo Ramos | 2012-04-02 20:48:33 +0200 |
---|---|---|
committer | Guillermo Ramos | 2012-04-02 20:48:33 +0200 |
commit | 8ae4691e677414843cf3a84d4327d303fe3e2f41 (patch) | |
tree | 6007373b702ece4100819606a82ecbae76ff1dd5 /io/myAverage.io | |
parent | fdd1e7abacd96d9bd49c13b2ecfcfe897546acae (diff) | |
download | 7l-8ae4691e677414843cf3a84d4327d303fe3e2f41.tar.gz |
[Io] Día 2
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 |