Hi Vivek, On Thu, Apr 29, 2010 at 8:37 PM, Vivek Ayer <vivek.a...@gmail.com> wrote: > Hi David, > > Thanks for the help. It's working! I still find it to be a new > concept. I haven't encountered storing loops in objects in any other > languages. Can it even be done in other languages? Very novel, quite > intriguing.
Yes, this idiom is quite frequently used in "functional" languages. You're not actually storing loops in objects, per se, though. Its somehow analogous to the "map" function, where you're traversing an input list of things/objects, and creating a new list of objects by transforming them. If you're familiar with python, think "list comprehensions". In your use case, your "inputs" are just sequence/index numbers, so it's not as natural to think of them this way, but imagine something like this: words <- c('one', 'two', 'three') capitalized <- for (word=words) %do% someCapitalizeFunction(word) which might give you c("One", "Two", "Three") This is just a pedagogical example, of course, but hopefully it helps to clear things up a bit? You're not storing loops in objects, but rather storing the transformed objects from your input list into a new list. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.