Computer Science Canada Using Arrays In Parimeters |
Author: | Prince Pwn [ Fri Dec 29, 2006 4:31 pm ] | ||
Post subject: | Using Arrays In Parimeters | ||
I'm kind of unsure how arrays in the parameters work, here's my code:
Everything is ok except for when I try to call the proc's/fcn's. |
Author: | [Gandalf] [ Fri Dec 29, 2006 4:41 pm ] | ||
Post subject: | |||
|
Author: | CodeMonkey2000 [ Fri Dec 29, 2006 4:53 pm ] |
Post subject: | |
Why do you use the variable "Foo"? is that a standard convention or something? bcause I saw many people use it in the tutorials. |
Author: | [Gandalf] [ Fri Dec 29, 2006 5:03 pm ] |
Post subject: | |
Yes, sort of. It's basically a standard convention for random naming. ![]() http://en.wikipedia.org/wiki/Metasyntactic_variable |
Author: | Hackmaster [ Fri Dec 29, 2006 7:47 pm ] |
Post subject: | |
foo is the first standard "I need a name for something" name. the second is bar. I think foobar is actually a word for something in another language... I dunno... wikipedia is you friend here. ![]() |
Author: | [Gandalf] [ Fri Dec 29, 2006 9:16 pm ] |
Post subject: | |
Hackmaster wrote: foo is the first standard "I need a name for something" name. the second is bar. I think foobar is actually a word for something in another language... I dunno... wikipedia is you friend here.
![]() Uhm... Did you even read my post? It's generally a good idea to read all the posts in a topic before replying. |
Author: | Prince Pwn [ Sun Dec 31, 2006 10:41 pm ] | ||||
Post subject: | |||||
Quote: Uhm... Did you even read my post? It's generally a good idea to read all the posts in a topic before replying.
hehe i do that sometimes, yeah we should learn to read all pages of a thread before we post. What I'm basically trying to do with this is actually make a procedure or function that will allow you to multiply as many numbers as you like just by calling:
or
So it wont matter how long my parameter is, it will still multiply all the values together without any errors. To do that I would think I'd have to have an array. Possibly a flexible array (which I am not 100% good with, but could learn). |
Author: | Cervantes [ Sun Dec 31, 2006 10:45 pm ] |
Post subject: | |
You can let your procedure take an array of unknown upper bound, but that's as good as it gets. There's no way to do that, I'm afraid. Just like there's no way to do default parameters. And there's no way to create an array without going through the trouble of creating a variable. Sorry. ![]() |
Author: | Clayton [ Mon Jan 01, 2007 3:01 pm ] | ||
Post subject: | |||
you can however do such a thing in Ruby ![]()
![]() |
Author: | Cervantes [ Mon Jan 01, 2007 3:48 pm ] | ||
Post subject: | |||
Better would be to use inject. It then becomes a one line function, and you aren't relying on that little bit of magic to get your value returned.
|
Author: | BenLi [ Tue Jan 02, 2007 10:35 am ] |
Post subject: | |
perhaps, foobar = fubar = f$cked up beyond all recognition |