On 07/07/2007 7:15 AM, (Ted Harding) wrote:
> On 07-Jul-07 10:34:03, Uwe Ligges wrote:
>> Alberto Monteiro wrote:
>>> Ted Harding wrote:
So I slickly wrote a recursive definition:
Nnk<-function(n,k){
if(n==1) {return(k)} else {
R<-0;
for(r in (1:k)) R<-(R+Nnk
On 07-Jul-07 10:34:03, Uwe Ligges wrote:
> Alberto Monteiro wrote:
>> Ted Harding wrote:
>>> So I slickly wrote a recursive definition:
>>>
>>> Nnk<-function(n,k){
>>> if(n==1) {return(k)} else {
>>> R<-0;
>>> for(r in (1:k)) R<-(R+Nnk(n-1,k-r+1)) # ,depth))
>>> }
>>> return(R)
>>> }
Alberto Monteiro wrote:
> Ted Harding wrote:
>> So I slickly wrote a recursive definition:
>>
>> Nnk<-function(n,k){
>> if(n==1) {return(k)} else {
>> R<-0;
>> for(r in (1:k)) R<-(R+Nnk(n-1,k-r+1)) # ,depth))
>> }
>> return(R)
>> }
>>
> You are aware that this is equivalent to:
>
>
Ted Harding wrote:
>
> So I slickly wrote a recursive definition:
>
> Nnk<-function(n,k){
> if(n==1) {return(k)} else {
> R<-0;
> for(r in (1:k)) R<-(R+Nnk(n-1,k-r+1)) # ,depth))
> }
> return(R)
> }
>
You are aware that this is equivalent to:
Nnk1 <- function(n, k) { prod(1:(n+k-1)
Hi Folks,
R has known speed issues for recursive definitions.
There was a thread "Extremely slow recursion in R?" in
August 2006 (24 Aug, from Jason Liao), with some
interesting comparisons between programming languages.
I'm re-opening the topic, with an ulterior motive
(stated at the end).
The