"Julia" (External Evaluation System)
Details
- Julia Version 0.7 and higher is supported. For ExternalFunction support, Julia 1.2 or higher is required.
- To configure Julia for use in the Wolfram Language, follow the instructions from the Configure Julia for ExternalEvaluate workflow.
ExternalEvaluate Usage
- ExternalEvaluate["Julia",code] executes the code string in a Julia REPL and returns the results as a Wolfram Language expression.
- ExternalEvaluate["Julia""String",code] executes the code string in a Julia REPL and returns the output as a Wolfram Language string.
Data Types
- The following Julia built-in types are supported:
-
Bool True False Boolean True/False values Int8, Int16, Int32, etc. Integer integer Float16, Float32, etc. Real real number Complex{Float16}, Complex{Float32}, etc. Complex complex number (returning from Julia only) String String string of characters Array List list of objects Dict Association associative array Set List unordered set without duplicates Tuple List fixed-length container Date, DateTime dates, date intervals NaN Indeterminate not-a-number nothing Null no return value
Examples
open allclose allBasic Examples (1)
Evaluate 2+2 in Julia and return the result:
Type > and select Julia from the drop-down menu to get a code cell that uses ExternalEvaluate to evaluate:
Dates are returned from Julia as DateObject expressions:
Scope (20)
Evaluate a Boolean statement in Julia and return the result:
Concatenate strings in Julia and return the result:
Dictionaries in Julia are returned as associations:
Arrays in Julia are returned as List:
Session Options (9)
"ReturnType" (3)
For the Julia evaluation system, the default return type is "Expression":
Numbers, strings, lists and associations are automatically imported for the "Expression" return type:
The return type of "String" returns a string of the result by calling the Julia function repr:
"Version" (1)
"Evaluator" (1)
Command Options (10)
"Command" (3)
When only a string of Julia code is provided, the command is directly executed:
The above is equivalent to writing the command using this form:
Use a File wrapper to run the code in a file:
The above is equivalent to writing the command using this form:
Put code in a CloudObject:
Evaluate directly from the cloud:
The above is equivalent to writing the command using this form:
"ReturnType" (1)
"Arguments" (2)
Use "Arguments" to call the result of the evaluation with arguments:
When a non-list argument is provided, a single argument is passed to the function:
If you need to pass a list as the first argument, you must wrap it with an extra list explicitly:
You can define a function inside "Command" and directly call it with "Arguments":
The same result can be achieved by using a Rule:
You can also pass arguments by creating an ExternalFunction:
"TemplateArguments" (3)
When running a command, you can inline a TemplateExpression:
You can explicitly fill TemplateSlot using "TemplateArguments":
When a non-list argument is provided, a single template argument is passed to the template:
If you need to pass a list as the first argument, you must wrap it with an extra list explicitly:
You can name template slots and use an Association to pass named arguments to the template:
Applications (2)
Use the mean function from the Statistics package in Julia:
Use the OrdinaryDiffEq package in Julia to solve a radioactive decay problem:
Properties & Relations (2)
Define a Wolfram Language function that calls a Julia function:
A NumericArray is sent to Julia as an array with the same element type: