def Sum(list): ret = 0 for value as int in list: ret = ret + value return ret list = (1, 2, 3, 4) for v in list: print(v) print Sum(list)This is really very simple: Lines 1 ~ 5 defines a function called Sum. Line 7 declares a variable (list) that holds an integer list from 1 to 4 Lines 8 ~9 prints this list to console, item by item Line 11 prints the result of Sum when called with list as the argument. Thats it. Adriano
Oct 24, 2007
Do you fear ghosts?
Well, me too, at least until one month ago :)
Seriously, a long time ago (maybe not so long), Rodrigo, a great friend of mine, started talking about write a new language for the .Net platform. Of course, I promptly ignored him, after all, who needs another computer language? Some time passed and I started to hear about a new language called Boo.
I was so deeply entrenched in my own world that it took me some time (and some books also :) to realize that that would be great to be exposed to a lot of new concepts (at least to me).
Well, yesterday I've wrote my first Boo program! Sure, it's a humble one but it's a start. In order to learn (not only the syntax, but a lot of concepts such closures, ducking typing, etc.) I'll try to write more code using boo from now on :)
And for those curious minds out there, here is my first piece of Boo code :)
Labels:
dotnet,
programing
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment