From 780ea3529172857354c5bff169e088fde907b84e Mon Sep 17 00:00:00 2001 From: eswagel <73608467+eswagel@users.noreply.github.com> Date: Mon, 29 Jul 2024 19:30:37 -0400 Subject: [PATCH] Updated version number in Project.toml --- Project.toml | 2 +- src/wcall.jl | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Project.toml b/Project.toml index f32503d..ae4e2c9 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SymbolicsMathLink" uuid = "7963cd39-1b62-4514-9cf0-788fb5452611" authors = ["E. Swagel"] -version = "1.0.1" +version = "2.0.0" [deps] MathLink = "18c93696-a329-5786-9845-8443133fa0b4" diff --git a/src/wcall.jl b/src/wcall.jl index a730502..bf2bce0 100644 --- a/src/wcall.jl +++ b/src/wcall.jl @@ -1,3 +1,4 @@ +function wcall(returnJulia::Union{Val{true}, Val{false}}, head::AbstractString, args...; kwargs...) """ wcall([returnJulia::Val{bool},] head::AbstractString, args...; returnJulia=Val(true), kwargs...) @@ -10,12 +11,12 @@ - `kwargs...`: Keyword arguments to the Mathematica function. These can be Symbolics, Julia types, or Mathematica types. # Returns - - If `returnJulia` is `false`, returns a Mathematica MathLink object representing the result of the Mathematica function. - - If `returnJulia` is `true` (default), returns a Julia expression representing the result of the Mathematica function. + - If `returnJulia` is `Val(false)`, returns a Mathematica MathLink object representing the result of the Mathematica function. + - If `returnJulia` is `Val(true)` (default), returns a Julia expression representing the result of the Mathematica function. # Examples ```julia - julia> wcall("Solve", x^2 + 2x + 1 == 0, returnJulia=false) + julia> wcall(Val(false), "Solve", x^2 + 2x + 1 == 0) MathLink.MathLinkObject(...) julia> wcall("Solve", x^2 + 2x + 1 == 0) @@ -24,12 +25,15 @@ -1 - x ``` """ -function wcall(::Val{false}, head::AbstractString, args...; kwargs...) - mathematica_result = wcall(head, args...; kwargs...) - return convert_to_julia(mathematica_result) + + return wcall(returnJulia, head, expr_to_mathematica.(args)...; kwargs...) +end +wcall(::Val{true}, head::AbstractString, args::Vararg{Mtypes}; kwargs...) = begin + mathematica_result = wcall(Val(false), head, args...; kwargs...) + return mathematica_to_expr(mathematica_result) end - wcall(::Val{true}, head::AbstractString, args...; kwargs...)=begin +wcall(::Val{false}, head::AbstractString, args::Vararg{Mtypes}; kwargs...) = begin return weval(MathLink.WSymbol(head)(args...; kwargs...)) end