promise already under evaluation: recursive default argument reference or earlier problems?

后端 未结 4 1519
渐次进展
渐次进展 2020-11-29 17:00

Here is my R code. The functions are defined as:

f <- function(x, T) {
  10 * sin(0.3 * x) * sin(1.3 * x ^ 2) + 0.001 * x ^ 3 + 0.2 * x + 80
}

g <- fu         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-29 17:49

    Formal arguments of the form x=x cause this. Eliminating the two instances where they occur we get:

    f <- function(x, T) {
       10 * sin(0.3 * x) * sin(1.3 * x^2) + 0.001 * x^3 + 0.2 * x + 80 
    }
    
    g <- function(x, T, f. = f) {  ## 1. note f.
       exp(-f.(x)/T) 
    }
    
    test<- function(g. = g, T = 1) {  ## 2. note g.
       g.(1,T) 
    }
    
    test()
    ## [1] 8.560335e-37
    

提交回复
热议问题