vendredi 1 février 2019

How to find if item is contained in Dict in Julia

I'm fairly new to Julia and am trying to figure out how to check if the given expression is contained in a Dict I've created.

function parse( expr::Array{Any} )
   if expr[1] == #check here if "expr[1]" is in "owl"
       return BinopNode(owl([expr[1]]), parse( expr[2] ), parse( expr[3] ) )
   end
end

owl = Dict(:+ => +, :- => -, :* => *, :/ => /)

I've looked at Julia's documentation and other resources, but can't find any answer to this.

"owl" is the name of my dictionary that I'm trying to check. I want to run the return statement should expr[1] be either "+,-,* or /".

Aucun commentaire:

Enregistrer un commentaire