If you mean replace a by 1 in the expression, you can do it as follows:

julia> e = :(typeof(a) <: Real && typeof(b) <: Real)
:(typeof(a) <: Real && typeof(b) <: Real)

julia> dump(e, 10)    # look at the structure of e
Expr
  head: Symbol &&
  args: Array(Any,(2,))
    1: Expr
      head: Symbol comparison
      args: Array(Any,(3,))
        1: Expr
          head: Symbol call
          args: Array(Any,(2,))
            1: Symbol typeof
            2: Symbol a
          typ: Any
        2: Symbol <:
        3: Symbol Real
      typ: Any
    2: Expr
      head: Symbol comparison
      args: Array(Any,(3,))
        1: Expr
          head: Symbol call
          args: Array(Any,(2,))
            1: Symbol typeof
            2: Symbol b
          typ: Any
        2: Symbol <:
        3: Symbol Real
      typ: Any
  typ: Any

julia> e.args[1].args[1].args[2]
:a

julia> e.args[1].args[1].args[2] = 1
1

julia> e
:(typeof(1) <: Real && typeof(b) <: Real)


On Tue, Jun 10, 2014 at 3:37 PM, Gustavo Lacerda
<[email protected]> wrote:
> hi,
>
> julia> parse("typeof(a)<:Real&&typeof(b)<:Real")
> :(typeof(a) <: Real && typeof(b) <: Real)
>
> I would like to substitute 'a' for 1 in this Expr.  Any suggestions?
>
> Gustavo
>
>
> --
> Gustavo Lacerda
> http://www.optimizelife.com

Reply via email to