If in fact this is homework, you will do yourself, your classmates, and possibly your teacher if you let them know that, at least in R, almost anything you can do in a for() loop can be done easier and faster with vectorization. If you teacher can't comprehend this, get him fired.

a<-c(4,6,3)
b<- c( 9,4,1)
d <- c(4,7,2,8)

winning.value <- max(outer(a,outer(b,d,"*"),"*"))


<quote>
From: R. Michael Weylandt <michael.weylandt_at_gmail.com>
Date: Sat, 05 Nov 2011 10:21:05 -0400
Why do you need to do it with nested for loops? It is of course possible - and I hinted how to do it in my first email - but there's no reason as far as I can see to do so, particularly as a means of MLE. Sounds suspiciously like homework...

Michael

On Nov 4, 2011, at 10:14 PM, nick_pan <nick_pan88_at_yahoo.gr> wrote:

> Thank you , this works but I have to do it with nested for loops...
>
> Could you suggest me a way ?
>
--

Sent from my Cray XK6
"Pendeo-navem mei anguillae plena est."

______________________________________________
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.

Reply via email to