Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Not all exercises, but I don't see any objetive in this language, and I'm not happy doing this, so, I will stop. I will not do the day 3*/
- /*some exercises from the book*/
- fib := method(result, (
- i := 0;
- res := list(0, 1);
- while(i < result, res append(res at(i) + res at(i+1)); i = i + 1);
- res at(i) println
- ))
- fib(4)
- fib(5)
- fib(6)
- fib(7)
- /*--------*/
- a := list(list(1,2,3), list(4,5,6), list(7,8,9))
- b := list(list(7,8,9), list(4,5,6), list(1,2,3))
- final := list()
- i := 0
- while(i < a size, final append((a at(i) sum) + (b at(i) sum)); i = i + 1); final sum println
- /*---------*/
- List myAverage := method(
- i := 0
- sum := 0
- while(i < self size, if(self at(i) type == "Number", sum = sum + self at(i), Exception raise("Not a number!")); i = i + 1)
- sum = sum / self size
- )
- list(1,2,3,4,5,6) myAverage println
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement