You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 lines
4.2 KiB

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>7. Example · Examples.jl</title><link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/4.2.0/normalize.min.css" rel="stylesheet" type="text/css"/><link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Mono" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.min.js" data-main="../assets/documenter.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link href="../assets/documenter.css" rel="stylesheet" type="text/css"/></head><body><nav class="toc"><h1>Examples.jl</h1><select id="version-selector" onChange="window.location.href=this.value" style="visibility: hidden"></select><form class="search" id="search-form" action="../search.html"><input id="search-query" name="q" type="text" placeholder="Search docs"/></form><ul><li><a class="toctext" href="../index.html"><strong>1.</strong> Introduction</a></li><li><a class="toctext" href="../fileformat.html"><strong>2.</strong> File Format</a></li><li><a class="toctext" href="../pipeline.html"><strong>3.</strong> Processing pipeline</a></li><li><a class="toctext" href="../outputformats.html"><strong>4.</strong> Output formats</a></li><li><a class="toctext" href="../customprocessing.html"><strong>5.</strong> Custom pre- and post-processing</a></li><li><a class="toctext" href="../documenter.html"><strong>6.</strong> Interaction with Documenter.jl</a></li><li class="current"><a class="toctext" href="example.html"><strong>7.</strong> Example</a><ul class="internal"><li><a class="toctext" href="#Rational-numbers-in-Julia-1">Rational numbers in Julia</a></li></ul></li></ul></nav><article id="docs"><header><nav><ul><li><a href="example.html"><strong>7.</strong> Example</a></li></ul><a class="edit-page" href="https://github.com/fredrikekre/Examples.jl/blob/master/docs/src/generated/example.md"><span class="fa"></span> Edit on GitHub</a></nav><hr/><div id="topbar"><span>7. Example</span><a class="fa fa-bars" href="#"></a></div></header><h1><a class="nav-anchor" id="**7.**-Example-1" href="#**7.**-Example-1"><strong>7.</strong> Example</a></h1><p><em>Output generated with Examples.jl based on <a href="../../../examples/example.jl">this</a> source file.</em></p><p>This is an example source file for input to Examples.jl.</p><p>If you are reading this you are seeing the markdown output generated from the source file, here you can see the corresponding notebook output: <a href="example.ipynb">example.ipynb</a></p><h2><a class="nav-anchor" id="Rational-numbers-in-Julia-1" href="#Rational-numbers-in-Julia-1">Rational numbers in Julia</a></h2><p>Rational number in julia can be constructed with the <code>//</code> operator:</p><div><pre><code class="language-julia">x = 1//3
y = 2//5</code></pre><pre><code class="language-none">2//5</code></pre></div><p>Operations with rational number returns a new rational number</p><div><pre><code class="language-julia">x + y</code></pre><pre><code class="language-none">11//15</code></pre></div><div><pre><code class="language-julia">x * y</code></pre><pre><code class="language-none">2//15</code></pre></div><p>Everytime a rational number is constructed, it will be simplified using the <code>gcd</code> function, for example <code>2//4</code> simplifies to <code>1//2</code>:</p><div><pre><code class="language-julia">2//4</code></pre><pre><code class="language-none">1//2</code></pre></div><p>and <code>2//4 + 2//4</code> simplifies to <code>1//1</code>:</p><div><pre><code class="language-julia">2//4 + 2//4</code></pre><pre><code class="language-none">1//1</code></pre></div><footer><hr/><a class="previous" href="../documenter.html"><span class="direction">Previous</span><span class="title"><strong>6.</strong> Interaction with Documenter.jl</span></a></footer></article></body></html>