Programming Language Manuals
Collection
5 items • Updated
text stringlengths 13 33.9k |
|---|
# Getting Started · The Julia Language
Source: https://docs.julialang.org/en/v1/manual/getting-started/ |
# [Getting Started](#man-getting-started)
Julia installation is straightforward, whether using precompiled binaries or compiling from source. Download and install Julia by following the instructions at <https://julialang.org/install/>.
If you are coming to Julia from one of the following languages, then you should star... |
# [Getting Started](#man-getting-started)
To exit the interactive session, type `CTRL-D` (press the Control/`^` key together with the `d` key), or type `exit()`. When run in interactive mode, `julia` displays a banner and prompts the user for input. Once the user has entered a complete expression, such as `1 + 2`, and ... |
## [Resources](#Resources)
A curated list of useful learning resources to help new users get started can be found on the [learning](https://julialang.org/learning/) page of the main Julia website.
You can use the REPL as a learning resource by switching into the help mode. Switch to help mode by pressing `?` at an empt... |
# Installation · The Julia Language
Source: https://docs.julialang.org/en/v1/manual/installation/ |
# [Installation](#man-installation)
There are many ways to install Julia. The following sections highlight the recommended method for each of the main supported platforms, and then present alternative ways that might be useful in specialized situations.
The current installation recommendation is a solution based on Jul... |
## [Windows](#Windows)
On Windows Julia can be installed directly from the Windows store [here](https://www.microsoft.com/store/apps/9NJNWW8PVKMN). One can also install exactly the same version by executing
```julia
winget install julia -s msstore
```
in any shell. |
## [Mac and Linux](#Mac-and-Linux)
Julia can be installed on Linux or Mac by executing
```julia
curl -fsSL https://install.julialang.org | sh
```
in a shell. |
### [Command line arguments](#Command-line-arguments)
One can pass various command line arguments to the Julia installer. The syntax for installer arguments is
```bash
curl -fsSL https://install.julialang.org | sh -s -- <ARGS>
```
Here `<ARGS>` should be replaced with one or more of the following arguments:
- `--yes`... |
## [Alternative installation methods](#Alternative-installation-methods)
Note that we recommend the following methods *only* if none of the installation methods described above work for your system.
Some of the installation methods described below recommend installing a package called `juliaup`. Note that this neverthe... |
### [App Installer (Windows)](#App-Installer-(Windows))
If the Windows Store is blocked on a system, we have an alternative [MSIX App Installer](https://learn.microsoft.com/en-us/windows/msix/app-installer/app-installer-file-overview) based setup. To use the App Installer version, download [this](https://install.julial... |
### [MSI Installer (Windows)](#MSI-Installer-(Windows))
If neither the Windows Store nor the App Installer version work on your Windows system, you can also use a MSI based installer. Note that this installation methods comes with serious limitations and is generally not recommended unless no other method works. For ex... |
### [Homebrew](https://brew.sh) (Mac and Linux)
On systems with brew, you can install Julia by running
```julia
brew install juliaup
```
in a shell. Note that you will have to update Juliaup with standard brew commands. |
### [Arch Linux - AUR](https://aur.archlinux.org/packages/juliaup/) (Linux)
On Arch Linux, Juliaup is available [in the Arch User Repository (AUR)](https://aur.archlinux.org/packages/juliaup/). |
### [openSUSE Tumbleweed](https://get.opensuse.org/tumbleweed/) (Linux)
On openSUSE Tumbleweed, you can install Julia by running
```sh
zypper install juliaup
```
in a shell with root privileges. |
### [cargo](https://crates.io/crates/juliaup/) (Windows, Mac and Linux)
To install Julia via Rust's cargo, run:
```sh
cargo install juliaup
```
------------------------------------------------------------------------ |
# Variables · The Julia Language
Source: https://docs.julialang.org/en/v1/manual/variables/ |
# [Variables](#man-variables)
A variable, in Julia, is a name associated (or bound) to a value. It's useful when you want to store a value (that you obtained after some math, for example) for later use. For example:
```julia-repl
# Assign the value 10 to the variable x
julia> x = 10
10
# Doing math with x's value
juli... |
# [Variables](#man-variables)
Julia will even let you shadow existing exported constants and functions with local ones (although this is not recommended to avoid potential confusions):
```julia-repl
julia> pi = 3
3
julia> pi
3
julia> sqrt = 4
4
julia> length() = 5
length (generic function with 1 method)
julia> Base... |
## [Allowed Variable Names](#man-allowed-variable-names)
Variable names must begin with a letter (A-Z or a-z), underscore, or a subset of Unicode code points greater than 00A0; in particular, [Unicode character categories](https://www.fileformat.info/info/unicode/category/index.htm) Lu/Ll/Lt/Lm/Lo/Nl (letters), Sc/So (... |
## [Allowed Variable Names](#man-allowed-variable-names)
A particular class of variable names is one that contains only underscores. These identifiers are write-only. I.e. they can only be assigned values, which are immediately discarded, and their values cannot be used in any way.
```julia-repl
julia> x, ___ = size([2... |
## [Allowed Variable Names](#man-allowed-variable-names)
Some Unicode characters are considered to be equivalent in identifiers. Different ways of entering Unicode combining characters (e.g., accents) are treated as equivalent (specifically, Julia identifiers are [NFC](https://en.wikipedia.org/wiki/Unicode_equivalence)... |
## [Assignment expressions and assignment versus mutation](#man-assignment-expressions)
An assignment `variable = value` "binds" the name `variable` to the `value` computed on the right-hand side, and the whole assignment is treated by Julia as an expression equal to the right-hand-side `value`. This means that assignm... |
## [Assignment expressions and assignment versus mutation](#man-assignment-expressions)
Here, the line `b = a` does *not* make a copy of the array `a`, it simply binds the name `b` to the *same* array `a`: both `b` and `a` "point" to one array `[1,2,3]` in memory. In contrast, an assignment `a[i] = value` *changes* the... |
## [Assignment expressions and assignment versus mutation](#man-assignment-expressions)
When you call a [function](../functions/#man-functions) in Julia, it behaves as if you *assigned* the argument values to new variable names corresponding to the function arguments, as discussed in [Argument-Passing Behavior](../func... |
## [Stylistic Conventions](#Stylistic-Conventions)
While Julia imposes few restrictions on valid names, it has become useful to adopt the following conventions:
- Names of variables are in lower case.
- Word separation can be indicated by underscores (`'_'`), but use of underscores is discouraged unless the name wo... |
# Integers and Floating-Point Numbers · The Julia Language
Source: https://docs.julialang.org/en/v1/manual/integers-and-floating-point-numbers/ |
# [Integers and Floating-Point Numbers](#Integers-and-Floating-Point-Numbers)
Integers and floating-point values are the basic building blocks of arithmetic and computation. Built-in representations of such values are called numeric primitives, while representations of integers and floating-point numbers as immediate v... |
# [Integers and Floating-Point Numbers](#Integers-and-Floating-Point-Numbers)
| Type | Signed? | Number of bits | Smallest value | Largest value |
|:----------------------------------------------|:--------|:---------------|:---------------|:--------------|
| [`Int8`](../../base/... |
# [Integers and Floating-Point Numbers](#Integers-and-Floating-Point-Numbers)
| Type | Precision | Number of bits |
|:----------------------------------------------|:--------------------------------------------... |
## [Integers](#Integers)
Literal integers are represented in the standard manner:
```julia-repl
julia> 1
1
julia> 1234
1234
```
The default type for an integer literal depends on whether the target system has a 32-bit architecture or a 64-bit architecture:
```julia-repl
# 32-bit system:
julia> typeof(1)
Int32
# 64-bi... |
## [Integers](#Integers)
```julia-repl
julia> x = 0x1
0x01
julia> typeof(x)
UInt8
julia> x = 0x123
0x0123
julia> typeof(x)
UInt16
julia> x = 0x1234567
0x01234567
julia> typeof(x)
UInt32
julia> x = 0x123456789abcdef
0x0123456789abcdef
julia> typeof(x)
UInt64
julia> x = 0x11112222333344445555666677778888
0x111122... |
## [Integers](#Integers)
Even if there are leading zero digits which don’t contribute to the value, they count for determining storage size of a literal. So `0x01` is a `UInt8` while `0x0001` is a `UInt16`.
That allows the user to control the size.
Unsigned literals (starting with `0x`) that encode integers too large t... |
## [Integers](#Integers)
```julia-repl
julia> (typemin(Int32), typemax(Int32))
(-2147483648, 2147483647)
julia> for T in [Int8,Int16,Int32,Int64,Int128,UInt8,UInt16,UInt32,UInt64,UInt128]
println("$(lpad(T,7)): [$(typemin(T)),$(typemax(T))]")
end
Int8: [-128,127]
Int16: [-32768,32767]
Int32: [... |
### [Overflow behavior](#Overflow-behavior)
In Julia, exceeding the maximum representable value of a given type results in a wraparound behavior:
```julia-repl
julia> x = typemax(Int64)
9223372036854775807
julia> x + 1
-9223372036854775808
julia> x + 1 == typemin(Int64)
true
```
Arithmetic operations with Julia's int... |
### [Division errors](#Division-errors)
Integer division (the `div` function) has two exceptional cases: dividing by zero, and dividing the lowest negative number ([`typemin`](../../base/base/#Base.typemin)) by -1. Both of these cases throw a [`DivideError`](../../base/base/#Core.DivideError). The remainder and modulus... |
## [Floating-Point Numbers](#Floating-Point-Numbers)
Literal floating-point numbers are represented in the standard formats, using [E-notation](https://en.wikipedia.org/wiki/Scientific_notation#E_notation) when necessary:
```julia-repl
julia> 1.0
1.0
julia> 1.
1.0
julia> 0.5
0.5
julia> .5
0.5
julia> -1.23
-1.23
ju... |
## [Floating-Point Numbers](#Floating-Point-Numbers)
Half-precision floating-point numbers are also supported ([`Float16`](../../base/numbers/#Core.Float16)) on all platforms, with native instructions used on hardware which supports this number format. Otherwise, operations are implemented in software, and use [`Float3... |
### [Floating-point zero](#Floating-point-zero)
Floating-point numbers have [two zeros](https://en.wikipedia.org/wiki/Signed_zero), positive zero and negative zero. They are equal to each other but have different binary representations, as can be seen using the [`bitstring`](../../base/numbers/#Base.bitstring) function... |
### [Special floating-point values](#Special-floating-point-values)
There are three specified standard floating-point values that do not correspond to any point on the real number line:
| `Float16` | `Float32` | `Float64` | Name | Description |
|:--------... |
### [Special floating-point values](#Special-floating-point-values)
The [`typemin`](../../base/base/#Base.typemin) and [`typemax`](../../base/base/#Base.typemax) functions also apply to floating-point types:
```julia-repl
julia> (typemin(Float16),typemax(Float16))
(-Inf16, Inf16)
julia> (typemin(Float32),typemax(Float... |
### [Machine epsilon](#Machine-epsilon)
Most real numbers cannot be represented exactly with floating-point numbers, and so for many purposes it is important to know the distance between two adjacent representable floating-point numbers, which is often known as [machine epsilon](https://en.wikipedia.org/wiki/Machine_ep... |
### [Machine epsilon](#Machine-epsilon)
The distance between two adjacent representable floating-point numbers is not constant, but is smaller for smaller values and larger for larger values. In other words, the representable floating-point numbers are densest in the real number line near zero, and grow sparser exponen... |
### [Rounding modes](#Rounding-modes)
If a number doesn't have an exact floating-point representation, it must be rounded to an appropriate representable value. However, the manner in which this rounding is done can be changed if required according to the rounding modes presented in the [IEEE 754 standard](https://en.w... |
### [Background and References](#Background-and-References)
Floating-point arithmetic entails many subtleties which can be surprising to users who are unfamiliar with the low-level implementation details. However, these subtleties are described in detail in most books on scientific computation, and also in the followin... |
### [Background and References](#Background-and-References)
- For even more extensive documentation of the history of, rationale for, and issues with floating-point numbers, as well as discussion of many other topics in numerical computing, see the [collected writings](https://people.eecs.berkeley.edu/~wkahan/) of [W... |
## [Arbitrary Precision Arithmetic](#Arbitrary-Precision-Arithmetic)
To allow computations with arbitrary-precision integers and floating point numbers, Julia wraps the [GNU Multiple Precision Arithmetic Library (GMP)](https://gmplib.org) and the [GNU MPFR Library](https://www.mpfr.org), respectively. The [`BigInt`](..... |
## [Arbitrary Precision Arithmetic](#Arbitrary-Precision-Arithmetic)
```julia-repl
julia> BigInt(typemax(Int64)) + 1
9223372036854775808
julia> big"123456789012345678901234567890" + 1
123456789012345678901234567891
julia> parse(BigInt, "123456789012345678901234567890") + 1
123456789012345678901234567891
julia> strin... |
## [Arbitrary Precision Arithmetic](#Arbitrary-Precision-Arithmetic)
The default precision (in number of bits of the significand) and rounding mode of [`BigFloat`](../../base/numbers/#Base.MPFR.BigFloat) operations can be changed globally by calling [`setprecision`](../../base/numbers/#Base.MPFR.setprecision) and [`set... |
## [Numeric Literal Coefficients](#man-numeric-literal-coefficients)
To make common numeric formulae and expressions clearer, Julia allows variables to be immediately preceded by a numeric literal, implying multiplication. This makes writing polynomial expressions much cleaner:
```julia-repl
julia> x = 3
3
julia> 2x^2... |
## [Numeric Literal Coefficients](#man-numeric-literal-coefficients)
```julia-repl
julia> (x-1)(x+1)
ERROR: MethodError: objects of type Int64 are not callable
julia> x(x+1)
ERROR: MethodError: objects of type Int64 are not callable
```
Both expressions are interpreted as function application: any expression that is n... |
### [Syntax Conflicts](#Syntax-Conflicts)
Juxtaposed literal coefficient syntax may conflict with some numeric literal syntaxes: hexadecimal, octal and binary integer literals and engineering notation for floating-point literals. Here are some situations where syntactic conflicts arise:
- The hexadecimal integer lite... |
## [Literal zero and one](#Literal-zero-and-one)
Julia provides functions which return literal 0 and 1 corresponding to a specified type or the type of a given variable.
| Function | Description |
|:-------------------------------------------|:-----... |
# Mathematical Operations and Elementary Functions · The Julia Language
Source: https://docs.julialang.org/en/v1/manual/mathematical-operations/ |
# [Mathematical Operations and Elementary Functions](#Mathematical-Operations-and-Elementary-Functions)
Julia provides a complete collection of basic arithmetic and bitwise operators across all of its numeric primitive types, as well as providing portable, efficient implementations of a comprehensive collection of stan... |
## [Arithmetic Operators](#Arithmetic-Operators)
The following [arithmetic operators](https://en.wikipedia.org/wiki/Arithmetic#Arithmetic_operations) are supported on all primitive numeric types:
| Expression | Name | Description |
|:-----------|:---------------|:-------------------... |
## [Arithmetic Operators](#Arithmetic-Operators)
Julia's promotion system makes arithmetic operations on mixtures of argument types "just work" naturally and automatically. See [Conversion and Promotion](../conversion-and-promotion/#conversion-and-promotion) for details of the promotion system.
The ÷ sign can be conven... |
## [Boolean Operators](#Boolean-Operators)
The following [Boolean operators](https://en.wikipedia.org/wiki/Boolean_algebra#Operations) are supported on [`Bool`](../../base/numbers/#Core.Bool) types:
| Expression | Name |
|:-----------|:---------------------... |
## [Bitwise Operators](#Bitwise-Operators)
The following [bitwise operators](https://en.wikipedia.org/wiki/Bitwise_operation#Bitwise_operators) are supported on all primitive integer types:
| Expression | Name |
|:-----------|:-------------------------... |
## [Updating operators](#Updating-operators)
Every binary arithmetic and bitwise operator also has an updating version that assigns the result of the operation back into its left operand. The updating version of the binary operator is formed by placing a `=` immediately after the operator. For example, writing `x += 3`... |
## [Vectorized "dot" operators](#man-dot-operators)
For *every* binary operation like `^`, there is a corresponding "dot" operation `.^` that is *automatically* defined to perform `^` element-by-element on arrays. For example, `[1, 2, 3] ^ 3` is not defined, since there is no standard mathematical meaning to "cubing" a... |
## [Vectorized "dot" operators](#man-dot-operators)
Furthermore, "dotted" updating operators like `a .+= b` (or `@. a += b`) are parsed as `a .= a .+ b`, where `.=` is a fused *in-place* assignment operation (see the [dot syntax documentation](../functions/#man-vectorized)).
Note the dot syntax is also applicable to us... |
## [Numeric Comparisons](#Numeric-Comparisons)
Standard comparison operations are defined for all the primitive numeric types:
| Operator | Name |
|:------------------------------------------------------------------------|:--------------... |
## [Numeric Comparisons](#Numeric-Comparisons)
- `Inf` is equal to itself and greater than everything else except `NaN`.
- `-Inf` is equal to itself and less than everything else except `NaN`.
- `NaN` is not equal to, not less than, and not greater than anything, including itself.
The last point is potentially su... |
## [Numeric Comparisons](#Numeric-Comparisons)
Mixed-type comparisons between signed integers, unsigned integers, and floats can be tricky. A great deal of care has been taken to ensure that Julia does them correctly.
For other types, `isequal` defaults to calling [`==`](../../base/math/#Base.:==), so if you want to de... |
### [Chaining comparisons](#Chaining-comparisons)
Unlike most languages, with the [notable exception of Python](https://en.wikipedia.org/wiki/Python_syntax_and_semantics#Comparison_operators), comparisons can be arbitrarily chained:
```julia-repl
julia> 1 < 2 <= 2 < 3 == 3 > 2 >= 1 == 1 < 3 != 5
true
```
Chaining compa... |
### [Elementary Functions](#Elementary-Functions)
Julia provides a comprehensive collection of mathematical functions and operators. These mathematical operations are defined over as broad a class of numerical values as permit sensible definitions, including integers, floating-point numbers, rationals, and complex numb... |
## [Operator Precedence and Associativity](#Operator-Precedence-and-Associativity)
Julia applies the following order and associativity of operations, from highest precedence to lowest:
| Category | Operators | Associativity ... |
## [Operator Precedence and Associativity](#Operator-Precedence-and-Associativity)
For a complete list of *every* Julia operator's precedence, see the top of this file: [`src/julia-parser.scm`](https://github.com/JuliaLang/julia/blob/master/src/julia-parser.scm). Note that some of the operators there are not defined in... |
## [Operator Precedence and Associativity](#Operator-Precedence-and-Associativity)
[Numeric literal coefficients](../integers-and-floating-point-numbers/#man-numeric-literal-coefficients), e.g. `2x`, are treated as multiplications with higher precedence than any other binary operation, with the exception of `^` where t... |
## [Numerical Conversions](#Numerical-Conversions)
Julia supports three forms of numerical conversion, which differ in their handling of inexact conversions.
- The notation `T(x)` or `convert(T, x)` converts `x` to a value of type `T`.
- If `T` is a floating-point type, the result is the nearest representable v... |
### [Rounding functions](#Rounding-functions)
| Function | Description | Return type |
|:---------------------------------------------|:---------------------------------|:------------|
| [`round(x)`](../../base/math/#Base.round) | round `x` to the nearest inte... |
### [Division functions](#Division-functions)
| Function | Description |
|:-------------------------------------------------|:------------------------------------------------------------... |
### [Sign and absolute value functions](#Sign-and-absolute-value-functions)
| Function | Description |
|:---------------------------------------------------|:-----------------------------------------------------------|
| [`abs(x)`]... |
### [Powers, logs and roots](#Powers,-logs-and-roots)
| Function | Description |
|:----------------------------------------------------------------------------|:-----------------------------... |
### [Powers, logs and roots](#Powers,-logs-and-roots)
For an overview of why functions like [`hypot`](../../base/math/#Base.Math.hypot), [`expm1`](../../base/math/#Base.expm1), and [`log1p`](../../base/math/#Base.log1p) are necessary and useful, see John D. Cook's excellent pair of blog posts on the subject: [expm1, lo... |
### [Trigonometric and hyperbolic functions](#Trigonometric-and-hyperbolic-functions)
All the standard trigonometric and hyperbolic functions are also defined:
```julia
sin cos tan cot sec csc
sinh cosh tanh coth sech csch
asin acos atan acot asec acsc
asinh acosh atanh acoth asec... |
### [Special functions](#Special-functions)
Many other special mathematical functions are provided by the package [SpecialFunctions.jl](https://github.com/JuliaMath/SpecialFunctions.jl).
- [1](#citeref-1)The unary operators `+` and `-` require explicit parentheses around their argument to disambiguate them from the o... |
# Complex and Rational Numbers · The Julia Language
Source: https://docs.julialang.org/en/v1/manual/complex-and-rational-numbers/ |
# [Complex and Rational Numbers](#Complex-and-Rational-Numbers)
Julia includes predefined types for both complex and rational numbers, and supports all the standard [Mathematical Operations and Elementary Functions](../mathematical-operations/#Mathematical-Operations-and-Elementary-Functions) on them. [Conversion and P... |
## [Complex Numbers](#Complex-Numbers)
The global constant [`im`](../../base/numbers/#Base.im) is bound to the complex number *i*, representing the principal square root of -1. (Using mathematicians' `i` or engineers' `j` for this global constant was rejected since they are such popular index variable names.) Since Jul... |
## [Complex Numbers](#Complex-Numbers)
Note that `3/4im == 3/(4*im) == -(3/4*im)`, since a literal coefficient binds more tightly than division.
Standard functions to manipulate complex values are provided:
```julia-repl
julia> z = 1 + 2im
1 + 2im
julia> real(1 + 2im) # real part of z
1
julia> imag(1 + 2im) # imagina... |
## [Complex Numbers](#Complex-Numbers)
Note that mathematical functions typically return real values when applied to real numbers and complex values when applied to complex numbers. For example, [`sqrt`](../../base/math/#Base.sqrt-Tuple%7BNumber%7D) behaves differently when applied to `-1` versus `-1 + 0im` even though... |
## [Complex Numbers](#Complex-Numbers)
```julia-repl
julia> 1 + Inf*im
1.0 + Inf*im
julia> 1 + NaN*im
1.0 + NaN*im
``` |
## [Rational Numbers](#Rational-Numbers)
Julia has a rational number type to represent exact ratios of integers. Rationals are constructed using the [`//`](../../base/math/#Base.://) operator:
```julia-repl
julia> 2//3
2//3
```
If the numerator and denominator of a rational have common factors, they are reduced to lowe... |
## [Rational Numbers](#Rational-Numbers)
```julia-repl
julia> a = 1; b = 2;
julia> isequal(float(a//b), a/b)
true
julia> a, b = 0, 0
(0, 0)
julia> float(a//b)
ERROR: ArgumentError: invalid rational: zero(Int64)//zero(Int64)
Stacktrace:
[...]
julia> a/b
NaN
julia> a, b = 0, -1
(0, -1)
julia> float(a//b), a/b
(0.0,... |
# Strings · The Julia Language
Source: https://docs.julialang.org/en/v1/manual/strings/ |
# [Strings](#man-strings)
Strings are finite sequences of characters. Of course, the real trouble comes when one asks what a character is. The characters that English speakers are familiar with are the letters `A`, `B`, `C`, etc., together with numerals and common punctuation symbols. These characters are standardized ... |
# [Strings](#man-strings)
There are a few noteworthy high-level features about Julia's strings:
- The built-in concrete type used for strings (and string literals) in Julia is [`String`](../../base/strings/#Core.String-Tuple%7BAbstractString%7D). This supports the full range of [Unicode](https://en.wikipedia.org/wiki... |
# [Strings](#man-strings)
- Conceptually, a string is a *partial function* from indices to characters: for some index values, no character value is returned, and instead an exception is thrown. This allows for efficient indexing into strings by the byte index of an encoded representation rather than by a character in... |
## [Characters](#man-characters)
A `Char` value represents a single character: it is just a 32-bit primitive type with a special literal representation and appropriate arithmetic behaviors, and which can be converted to a numeric value representing a [Unicode code point](https://en.wikipedia.org/wiki/Code_point). (Juli... |
## [Characters](#man-characters)
As of this writing, the valid Unicode code points are `U+0000` through `U+D7FF` and `U+E000` through `U+10FFFF`. These have not all been assigned intelligible meanings yet, nor are they necessarily interpretable by applications, but all of these values are considered to be valid Unicode... |
## [Characters](#man-characters)
```julia-repl
julia> 'A' < 'a'
true
julia> 'A' <= 'a' <= 'Z'
false
julia> 'A' <= 'X' <= 'Z'
true
julia> 'x' - 'a'
23
julia> 'A' + 1
'B': ASCII/Unicode U+0042 (category Lu: Letter, uppercase)
``` |
## [String Basics](#String-Basics)
String literals are delimited by double quotes or triple double quotes (not single quotes):
```julia-repl
julia> str = "Hello, world.\n"
"Hello, world.\n"
julia> """Contains "quote" characters"""
"Contains \"quote\" characters"
```
Long lines in strings can be broken up by preceding ... |
## [String Basics](#String-Basics)
You can perform arithmetic and other operations with [`end`](../../base/base/#end), just like a normal value:
```julia-repl
julia> str[end-1]
'.': ASCII/Unicode U+002E (category Po: Punctuation, other)
julia> str[end÷2]
' ': ASCII/Unicode U+0020 (category Zs: Separator, space)
```
Us... |
## [String Basics](#String-Basics)
```julia-repl
julia> str = "long string"
"long string"
julia> substr = SubString(str, 1, 4)
"long"
julia> typeof(substr)
SubString{String}
julia> @views typeof(str[1:4]) # @views converts slices to SubStrings
SubString{String}
```
Several standard functions like [`chop`](../../base... |
## [Unicode and UTF-8](#Unicode-and-UTF-8)
Julia fully supports Unicode characters and strings. As [discussed above](#man-characters), in character literals, Unicode code points can be represented using Unicode `\u` and `\U` escape sequences, as well as all the standard C escape sequences. These can likewise be used to... |
## [Unicode and UTF-8](#Unicode-and-UTF-8)
```julia-repl
julia> s[1]
'∀': Unicode U+2200 (category Sm: Symbol, math)
julia> s[2]
ERROR: StringIndexError: invalid index [2], valid nearby indices [1]=>'∀', [4]=>' '
Stacktrace:
[...]
julia> s[3]
ERROR: StringIndexError: invalid index [3], valid nearby indices [1]=>'∀', ... |
## [Unicode and UTF-8](#Unicode-and-UTF-8)
Extraction of a substring using range indexing also expects valid byte indices or an error is thrown:
```julia-repl
julia> s[1:1]
"∀"
julia> s[1:2]
ERROR: StringIndexError: invalid index [2], valid nearby indices [1]=>'∀', [4]=>' '
Stacktrace:
[...]
julia> s[1:4]
"∀ "
```
Be... |
## [Unicode and UTF-8](#Unicode-and-UTF-8)
If you need to obtain valid indices for a string, you can use the [`nextind`](../../base/arrays/#Base.nextind) and [`prevind`](../../base/arrays/#Base.prevind) functions to increment/decrement to the next/previous valid index, as mentioned above. You can also use the [`eachind... |
This dataset contains the Julia programming language documentation, chunked using semantic parsing for pretraining language models.
Updated: 2025-09-08
from datasets import load_dataset
ds = load_dataset("json", data_files={"train": "train.jsonl"}, split="train")
text field per line