WL (.wl, .m)
Background & Context
-
- MIME type: application/vnd.wolfram.wl, application/vnd.wolfram.mathematica.package
- Wolfram Language package source format.
- Used for storing and exchanging Wolfram Language programs, packages and data.
- Plain ASCII text format.
- Stores Wolfram Language expressions in InputForm.
- Can represent program code, numerical and textual data, 2D raster and vector images, 3D geometries, sound and other kinds of data.
- Developed since 1988 by Wolfram Research.
Import & Export
- Import["file.wl"] reads in a Wolfram Language package, evaluating each expression in it and returning the last one.
- Export["file.wl",expr] exports a single expression to a package source file.
- The Wolfram Language always uses CharacterEncoding->"ASCII" for package source files.
- Import["file.wl",elem] imports the specified element from a package source file.
- Import["file.wl",{elem,suba,subb,…}] imports a subelement.
- Import["file.wl",{{elem1,elem2,…}}] imports multiple elements.
- The import format can be specified with Import["file","WL"] or Import["file",{"Package",elem,…}].
- Import["file.wl"] is equivalent to Get["file.wl"].
- Export["file.wl",expr,elem] creates a Wolfram Language source file by treating expr as specifying element elem.
- Export["file.wl",{expr1,expr2,…},{{elem1,elem2,…}}] treats each expri as specifying the corresponding elemi.
- Export["file.wl",expr,opt1->val1,…] exports expr with the specified option elements taken to have the specified values.
- Export["file.wl",{elem1->expr1,elem2->expr2,…},"Rules"] uses rules to specify the elements to be exported.
- Put[expr1,expr2,…,"file.wl"] can be used to export multiple expressions.
- See the following reference pages for full general information:
-
Import, Export import from or export to a file CloudImport, CloudExport import from or export to a cloud object ImportString, ExportString import from or export to a string ImportByteArray, ExportByteArray import from or export to a byte array
Import Elements
- General Import elements:
-
"Elements" list of elements and options available in this file "Summary" summary of the file "Rules" list of rules for all available elements - Import elements:
-
"ExpressionList" evaluates all expressions and returns the results as a list "Get" reads and evaluates all expressions, returning the last one "HeldExpressions" list of unevaluated expressions "InactivatedExpressions" list of inactivated expressions "ExprStructs" list of "ExprStruct" data structures "Comments" code comments - Import by default uses the "Get" element for Wolfram Language package files.
Examples
Basic Examples (4)
Show the Import elements available in a sample file:
Import unevaluated expressions from this file:
Import all expressions and run them through Inactivate:
Import only the first expression from the package in Inactive form:
Export an arbitrary expression to the package format:
Import an expression into an "ExprStruct" data structure: