Try quoting the entire function with :(...), like so:

julia> a=:(function ode_test(t, x, p)
           AB = x[1]
           At = p[1]
           Bt = p[2]
           kon = p[3]
           koff = p[4]
           A = At - AB
           B = Bt - AB

           dAB = kon*A*B - koff*AB
       end)

:(function ode_test(t,x,p) # none, line 2:
        AB = x[1] # line 3:
        At = p[1] # line 4:
        Bt = p[2] # line 5:
        kon = p[3] # line 6:
        koff = p[4] # line 7:
        A = -(At,AB) # line 8:
        B = -(Bt,AB) # line 10:
        dAB = -(*(kon,A,B),*(koff,AB))
    end)

This gives you an expression (Expr) which consists of a function
definition (a.head == :function), the signature

julia> a.args[1]
:(ode_test(t,x,p))

and the body of the function, which is a block expression:

julia> a.args[2].head
:block

whose contents you can access with .args:

julia> a.args[2].args
16-element Array{Any,1}:
 :( # none, line 2:)
 :(AB = x[1])
 :( # line 3:)
 :(At = p[1])
 :( # line 4:)
 :(Bt = p[2])
 :( # line 5:)
 :(kon = p[3])
 :( # line 6:)
 :(koff = p[4])
 :( # line 7:)
 :(A = -(At,AB))
 :( # line 8:)
 :(B = -(Bt,AB))
 :( # line 10:)
 :(dAB = -(*(kon,A,B),*(koff,AB)))



The metaprogramming chapter of the manual should be able to help you further.

Reply via email to