How to pass parameter list to a function in Julia

后端 未结 5 704
名媛妹妹
名媛妹妹 2021-01-25 07:27

I am newbie in Julia language, and the tutorial is not very deep yet and I didn\'t understand what is the best way to pass a parameter list of a function. My function looks like

5条回答
  •  伪装坚强ぢ
    2021-01-25 07:34

    To me it sounds like you're looking for anonymous functions. For example:

    function dxdt_parametric(x, a, b, c)
       a*x^2 + b*x + c
    end
    
    a = 1
    b = 2
    c = 1
    
    julia> dxdt = x->dxdt_parametric(x, a, b, c)
    (anonymous function)
    
    julia> dxdt(3.2)
    17.64
    

提交回复
热议问题