7. Example
Output generated with Examples.jl based on this source file.
This is an example source file for input to Examples.jl.
If you are reading this you are seeing the markdown output generated from the source file, here you can see the corresponding notebook output: example.ipynb
Rational numbers in Julia
Rational number in julia can be constructed with the // operator:
x = 1//3
+7. Example · Examples.jl
7. Example
This is an example for Examples.jl. The source file can be found here. The generated markdown can be found here: example.md, the generated notebook can be found here: example.ipynb, and the plain script output can be found here: example.jl.
Rational numbers in Julia
Rational number in julia can be constructed with the // operator:
x = 1//3
y = 2//5
2//5
Operations with rational number returns a new rational number
x + y
11//15
x * y
2//15
Everytime a rational number is constructed, it will be simplified using the gcd function, for example 2//4 simplifies to 1//2:
2//4
1//2
and 2//4 + 2//4 simplifies to 1//1:
2//4 + 2//4
1//1
diff --git a/latest/generated/example.ipynb b/latest/generated/example.ipynb
index f33d0ed..9bd5ea2 100644
--- a/latest/generated/example.ipynb
+++ b/latest/generated/example.ipynb
@@ -6,14 +6,12 @@
"source": [
"# **7.** Example\n",
"\n",
- "*Output generated with Examples.jl based on\n",
- "[this](../../../examples/example.jl) source file.*\n",
- "\n",
- "This is an example source file for input to Examples.jl.\n",
- "\n",
- "If you are reading this you are seeing the notebook output\n",
- "generated from the source file, here you can see the corresponding\n",
- "markdown output: [example.md](./example.md)"
+ "This is an example for Examples.jl.\n",
+ "The source file can be found [here](https://github.com/fredrikekre/Examples.jl/blob/master/examples/example.jl).\n",
+ "The generated markdown can be found here: [`example.md`](./example.md), the\n",
+ "generated notebook can be found here:\n",
+ "[`example.ipynb`](https://nbviewer.jupyter.org/github/fredrikekre/Examples.jl/blob/gh-pages/latest/generated/example.ipynb), and the\n",
+ "plain script output can be found here: [`example.jl`](./example.jl)."
],
"metadata": {}
},
@@ -21,20 +19,29 @@
"outputs": [],
"cell_type": "markdown",
"source": [
- "## Rational numbers in Julia\n",
+ "### Rational numbers in Julia\n",
"Rational number in julia can be constructed with the `//` operator:"
],
"metadata": {}
},
{
- "outputs": [],
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": "2//5"
+ },
+ "metadata": {},
+ "execution_count": 1
+ }
+ ],
"cell_type": "code",
"source": [
"x = 1//3\n",
"y = 2//5"
],
"metadata": {},
- "execution_count": null
+ "execution_count": 1
},
{
"outputs": [],
@@ -45,22 +52,40 @@
"metadata": {}
},
{
- "outputs": [],
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": "11//15"
+ },
+ "metadata": {},
+ "execution_count": 2
+ }
+ ],
"cell_type": "code",
"source": [
"x + y"
],
"metadata": {},
- "execution_count": null
+ "execution_count": 2
},
{
- "outputs": [],
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": "2//15"
+ },
+ "metadata": {},
+ "execution_count": 3
+ }
+ ],
"cell_type": "code",
"source": [
"x * y"
],
"metadata": {},
- "execution_count": null
+ "execution_count": 3
},
{
"outputs": [],
@@ -72,13 +97,22 @@
"metadata": {}
},
{
- "outputs": [],
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": "1//2"
+ },
+ "metadata": {},
+ "execution_count": 4
+ }
+ ],
"cell_type": "code",
"source": [
"2//4"
],
"metadata": {},
- "execution_count": null
+ "execution_count": 4
},
{
"outputs": [],
@@ -89,13 +123,22 @@
"metadata": {}
},
{
- "outputs": [],
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": "1//1"
+ },
+ "metadata": {},
+ "execution_count": 5
+ }
+ ],
"cell_type": "code",
"source": [
"2//4 + 2//4"
],
"metadata": {},
- "execution_count": null
+ "execution_count": 5
}
],
"nbformat_minor": 3,
diff --git a/latest/outputformats.html b/latest/outputformats.html
index 6228de1..65dfc73 100644
--- a/latest/outputformats.html
+++ b/latest/outputformats.html
@@ -17,4 +17,4 @@ Here is an example with some code
```@example
x = sin.(cos.([1, 2, 3]))
y = x.^2 - x
-```Examples.markdown — Function.Examples.markdown(inputfile, outputdir; kwargs...)Generate a markdown file from inputfile and write the result to the directoryoutputdir.
Keyword arguments:
name: name of the output file, excluding.md.nameis also used to name all the@exampleblocks. Defaults to the filename ofinputfile.preprocess,postprocess: custom pre- and post-processing functions, see the Custom pre- and post-processing section of the manual. Defaults toidentity.codefence: APairof opening and closing code fence. Defaults to
if"```julia" => "```"documenter = falseand
if"```@example $(name)" => "```"documenter = true.documenter: boolean that says if the output is intended to use with Documenter.jl. Defaults tofalse. See the the manual section on Interaction with Documenter.
4.2. Notebook output
Examples.notebook — Function.Examples.notebook(inputfile, outputdir; kwargs...)Generate a notebook from inputfile and write the result to outputdir.
Keyword arguments:
name: name of the output file, excluding.ipynb. Defaults to the filename ofinputfile.preprocess,postprocess: custom pre- and post-processing functions, see the Custom pre- and post-processing section of the manual. Defaults toidentity.execute: a boolean deciding if the generated notebook should also be executed or not. Defaults tofalse.documenter: boolean that says if the source contains Documenter.jl specific things to filter out during notebook generation. Defaults tofalse. See the the manual section on Interaction with Documenter.
4.3. Script output
Examples.script — Function.Examples.script(inputfile, outputdir; kwargs...)Generate a plain script file from inputfile and write the result to outputdir.
Keyword arguments:
name: name of the output file, excluding.jl. Defaults to the filename ofinputfile.preprocess,postprocess: custom pre- and post-processing functions, see the Custom pre- and post-processing section of the manual. Defaults toidentity.
Examples.markdown — Function.Examples.markdown(inputfile, outputdir; kwargs...)Generate a markdown file from inputfile and write the result to the directoryoutputdir.
Keyword arguments:
name: name of the output file, excluding.md.nameis also used to name all the@exampleblocks. Defaults to the filename ofinputfile.preprocess,postprocess: custom pre- and post-processing functions, see the Custom pre- and post-processing section of the manual. Defaults toidentity.documenter: boolean that tells if the output is intended to use with Documenter.jl. Defaults totrue. See the the manual section on Interaction with Documenter.codefence: APairof opening and closing code fence. Defaults to
if"```@example $(name)" => "```"documenter = trueand
if"```julia" => "```"documenter = false.
4.2. Notebook output
Examples.notebook — Function.Examples.notebook(inputfile, outputdir; kwargs...)Generate a notebook from inputfile and write the result to outputdir.
Keyword arguments:
name: name of the output file, excluding.ipynb. Defaults to the filename ofinputfile.preprocess,postprocess: custom pre- and post-processing functions, see the Custom pre- and post-processing section of the manual. Defaults toidentity.execute: a boolean deciding if the generated notebook should also be executed or not. Defaults totrue.documenter: boolean that says if the source contains Documenter.jl specific things to filter out during notebook generation. Defaults totrue. See the the manual section on Interaction with Documenter.
4.3. Script output
Examples.script — Function.Examples.script(inputfile, outputdir; kwargs...)Generate a plain script file from inputfile and write the result to outputdir.
Keyword arguments:
name: name of the output file, excluding.jl. Defaults to the filename ofinputfile.preprocess,postprocess: custom pre- and post-processing functions, see the Custom pre- and post-processing section of the manual. Defaults toidentity.