mirror of
https://github.com/redoules/redoules.github.io.git
synced 2025-12-12 15:59:34 +00:00
added 3 new articles
bash functions edges in a graph reverse list
This commit is contained in:
parent
9501c4183e
commit
606295d39f
@ -286,7 +286,7 @@ maxuploadtarget=5000
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -161,7 +161,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
BIN
images/Number_of_edges_in_a_Complete_graph/complete_graph.png
Normal file
BIN
images/Number_of_edges_in_a_Complete_graph/complete_graph.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 102 KiB |
@ -366,6 +366,7 @@
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
<li><a href="./python/reverse.html">Reverse an array</a></li>
|
||||
<li><a href="./python/design_own_libs.html">Advice for designing your own libraries</a></li>
|
||||
<li><a href="./python/ensure_dir.html">Safely creating a folder if it doesn't exist</a></li>
|
||||
<li><a href="./python/list_files_directory.html">List all files in a directory</a></li>
|
||||
@ -578,6 +579,7 @@
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
<li><a href="./linux/simple_bash_function.html">Create a simple bash function</a></li>
|
||||
<li><a href="./linux/bashrc.html">What's inside my .bashrc ?</a></li>
|
||||
<li><a href="./linux/linux_process_information.html">How to check Linux process information?</a></li>
|
||||
<li><a href="./linux/directory_size.html">Check the size of a directory</a></li>
|
||||
@ -644,7 +646,7 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
<li>Coming soon.</li>
|
||||
<li><a href="./mathematics/Number_edges_Complete_graph.html">Number of edges in a Complete graph</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -670,7 +672,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -149,7 +149,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -211,7 +211,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -144,7 +144,7 @@ However, you can use the following command to do it </p>
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -143,7 +143,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -203,7 +203,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -148,7 +148,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -167,7 +167,7 @@ none 0 0 0 - /config
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -256,7 +256,7 @@ wifi0 Link encap:UNSPEC HWaddr 5C-51-4F-41-7A-AD-00-00-00-00-00-00-00-00-00
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -172,7 +172,7 @@ USER;PID;%CPU;%MEM;VSZ;RSS;TTY;STAT;START;TIME;COMMAND</p>
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -158,7 +158,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -151,7 +151,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
257
linux/simple_bash_function.html
Normal file
257
linux/simple_bash_function.html
Normal file
@ -0,0 +1,257 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
||||
<meta name="description" content="Data Science for Political and Social Phenomena">
|
||||
<meta name="author" content="Guillaume Redoulès">
|
||||
<link rel="icon" href="../favicon.ico">
|
||||
|
||||
<title>Create a simple bash function - Linux</title>
|
||||
|
||||
<!-- JQuery -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
|
||||
<script>
|
||||
window.jQuery || document.write('<script src="../theme/js/jquery.min.js"><\/script>')
|
||||
</script>
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link rel="stylesheet" href="../theme/css/bootstrap.css" />
|
||||
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/ie10-viewport-bug-workaround.css" />
|
||||
<!-- Custom styles for this template -->
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/notebooks.css" />
|
||||
<link href='https://fonts.googleapis.com/css?family=PT+Serif:400,700|Roboto:400,500,700' rel='stylesheet' type='text/css'>
|
||||
|
||||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
<meta name="tags" content="Bash" />
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="..">Guillaume Redoulès</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse" id="searchbar">
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="../pages/about.html">About Guillaume</a></li>
|
||||
<li><a href="https://github.com/redoules">GitHub</a></li>
|
||||
<li><a href="https://www.linkedin.com/in/guillaume-redoul%C3%A8s-33923860/">LinkedIn</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Data Science<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="..#Blog">Blog</a></li>
|
||||
<li><a href="..#Python">Python</a></li>
|
||||
<li><a href="..#Bash">Bash</a></li>
|
||||
<li><a href="..#SQL">SQL</a></li>
|
||||
<li><a href="..#Mathematics">Mathematics</a></li>
|
||||
<li><a href="..#Machine_Learning">Machine Learning</a></li>
|
||||
<li><a href="..#Projects">Projects</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Projects<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="https://github.com/redoules/redoules.github.io">Notes (Github)</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<!--<li class="dropdown">
|
||||
<a href="../feeds/blog.rss.xml">Blog RSS</a>
|
||||
</li>-->
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
<form class="navbar-form" action="../search.html" onsubmit="return validateForm(this.elements['q'].value);">
|
||||
<div class="form-group" style="display:inline;">
|
||||
<div class="input-group" style="display:table;">
|
||||
<span class="input-group-addon" style="width:1%;"><span class="glyphicon glyphicon-search"></span></span>
|
||||
<input class="form-control search-query" name="q" id="tipue_search_input" placeholder="e.g. scikit KNN, pandas merge" required autocomplete="off" type="text">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- end of header section -->
|
||||
<div class="container">
|
||||
<!-- <div class="alert alert-warning" role="alert">
|
||||
Did you find this page useful? Please do me a quick favor and <a href="#" class="alert-link">endorse me for data science on LinkedIn</a>.
|
||||
</div> -->
|
||||
<section id="content" class="body">
|
||||
<header>
|
||||
<h1>
|
||||
Create a simple bash function
|
||||
</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
<time class="published" datetime="2018-11-07T09:37:00+01:00">
|
||||
07 novembre 2018
|
||||
</time>
|
||||
</li>
|
||||
<li>Linux</li>
|
||||
<li>Bash</li>
|
||||
</ol>
|
||||
</header>
|
||||
<div class='article_content'>
|
||||
<h2>A basic function</h2>
|
||||
<p>The synthaxe to define a function is :</p>
|
||||
<div class="highlight"><pre><span></span><span class="ch">#!/bin/bash</span>
|
||||
<span class="c1"># Basic function</span>
|
||||
my_function <span class="o">()</span> <span class="o">{</span>
|
||||
<span class="nb">echo</span> Text displayed by my_function
|
||||
<span class="o">}</span>
|
||||
|
||||
<span class="c1">#once defined, you can use it like so :</span>
|
||||
my_function
|
||||
</pre></div>
|
||||
|
||||
|
||||
<p>and it should return </p>
|
||||
<div class="highlight"><pre><span></span>user@bash : ./my_function.sh
|
||||
Text displayed by my_function
|
||||
</pre></div>
|
||||
|
||||
|
||||
<h2>Function with arguments</h2>
|
||||
<p>When used, the arguments are specified directly after the function name. Whithin the function they are accessible this the $ symbol followed by the number of the arguement.</p>
|
||||
<p>Hence <code>$1</code> will take the value of the first arguement, <code>$2</code> will take the value of the second arguement and so on.</p>
|
||||
<div class="highlight"><pre><span></span><span class="ch">#!/bin/bash</span>
|
||||
<span class="c1"># Passing arguments to a function</span>
|
||||
say_hello <span class="o">()</span> <span class="o">{</span>
|
||||
<span class="nb">echo</span> Hello <span class="nv">$1</span>
|
||||
<span class="o">}</span>
|
||||
say_hello Guillaume
|
||||
</pre></div>
|
||||
|
||||
|
||||
<p>and it should return </p>
|
||||
<div class="highlight"><pre><span></span>user@bash : ./function_arguements.sh
|
||||
Hello Guillaume
|
||||
</pre></div>
|
||||
|
||||
|
||||
<h2>Overriding Commands</h2>
|
||||
<p>Using the previous example, let's override the echo function in order to make it say hello. To do so, you just need to name the function with the same name as the command you want to replace. When you are calling the original function, make sure you are using the <code>builtin</code> keyword </p>
|
||||
<div class="highlight"><pre><span></span><span class="ch">#!/bin/bash</span>
|
||||
<span class="c1"># Overriding a function</span>
|
||||
<span class="nb">echo</span> <span class="o">()</span> <span class="o">{</span>
|
||||
<span class="nb">builtin</span> <span class="nb">echo</span> Hello <span class="nv">$1</span>
|
||||
<span class="o">}</span>
|
||||
<span class="nb">echo</span> Guillaume
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div class="highlight"><pre><span></span>user@bash : ./function_arguements.sh
|
||||
Hello Guillaume
|
||||
</pre></div>
|
||||
|
||||
|
||||
<h2>Returning values</h2>
|
||||
<p>Use the keyword return to send back a value to the main program. The returned value will be stored in the <code>$?</code> variable</p>
|
||||
<div class="highlight"><pre><span></span><span class="ch">#!/bin/bash</span>
|
||||
<span class="c1"># Retruning a value </span>
|
||||
secret_number <span class="o">()</span> <span class="o">{</span>
|
||||
<span class="k">return</span> <span class="m">126</span>
|
||||
<span class="o">}</span>
|
||||
secret_number
|
||||
<span class="nb">echo</span> The secret number is <span class="nv">$?</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<p>This code should return </p>
|
||||
<div class="highlight"><pre><span></span>user@bash : ./retrun_value.sh
|
||||
The secret number is 126
|
||||
</pre></div>
|
||||
</div>
|
||||
<aside>
|
||||
<div class="bug-reporting__panel">
|
||||
<h3>Find an error or bug? Have a suggestion?</h3>
|
||||
<p>Everything on this site is avaliable on GitHub. Head on over and <a href='https://github.com/redoules/redoules.github.io/issues/new'>submit an issue.</a> You can also message me directly by <a href='mailto:guillaume.redoules@gadz.org'>email</a>.</p>
|
||||
</div>
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<!-- start of footer section -->
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
</center>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- This jQuery line finds any span that contains code highlighting classes and then selects the parent <pre> tag and adds a border. This is done as a workaround to visually distinguish the code inputs and outputs -->
|
||||
<script>
|
||||
$( ".hll, .n, .c, .err, .k, .o, .cm, .cp, .c1, .cs, .gd, .ge, .gr, .gh, .gi, .go, .gp, .gs, .gu, .gt, .kc, .kd, .kn, .kp, .kr, .kt, .m, .s, .na, .nb, .nc, .no, .nd, .ni, .ne, .nf, .nl, .nn, .nt, .nv, .ow, .w, .mf, .mh, .mi, .mo, .sb, .sc, .sd, .s2, .se, .sh, .si, .sx, .sr, .s1, .ss, .bp, .vc, .vg, .vi, .il" ).parent( "pre" ).css( "border", "1px solid #DEDEDE" );
|
||||
</script>
|
||||
|
||||
|
||||
<!-- Load Google Analytics -->
|
||||
<script>
|
||||
/*
|
||||
(function(i, s, o, g, r, a, m) {
|
||||
i['GoogleAnalyticsObject'] = r;
|
||||
i[r] = i[r] || function() {
|
||||
(i[r].q = i[r].q || []).push(arguments)
|
||||
}, i[r].l = 1 * new Date();
|
||||
a = s.createElement(o),
|
||||
m = s.getElementsByTagName(o)[0];
|
||||
a.async = 1;
|
||||
a.src = g;
|
||||
m.parentNode.insertBefore(a, m)
|
||||
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
||||
|
||||
ga('create', 'UA-66582-32', 'auto');
|
||||
ga('send', 'pageview');
|
||||
*/
|
||||
</script>
|
||||
<!-- End of Google Analytics -->
|
||||
|
||||
<!-- Bootstrap core JavaScript
|
||||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<script src="../theme/js/bootstrap.min.js"></script>
|
||||
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
||||
<script src="../theme/js/ie10-viewport-bug-workaround.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -160,7 +160,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -1033,7 +1033,7 @@ Top dislike features:
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
190
mathematics/Number_edges_Complete_graph.html
Normal file
190
mathematics/Number_edges_Complete_graph.html
Normal file
@ -0,0 +1,190 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
||||
<meta name="description" content="Data Science for Political and Social Phenomena">
|
||||
<meta name="author" content="Guillaume Redoulès">
|
||||
<link rel="icon" href="../favicon.ico">
|
||||
|
||||
<title>Number of edges in a Complete graph - Mathematics</title>
|
||||
|
||||
<!-- JQuery -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
|
||||
<script>
|
||||
window.jQuery || document.write('<script src="../theme/js/jquery.min.js"><\/script>')
|
||||
</script>
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link rel="stylesheet" href="../theme/css/bootstrap.css" />
|
||||
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/ie10-viewport-bug-workaround.css" />
|
||||
<!-- Custom styles for this template -->
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/notebooks.css" />
|
||||
<link href='https://fonts.googleapis.com/css?family=PT+Serif:400,700|Roboto:400,500,700' rel='stylesheet' type='text/css'>
|
||||
|
||||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
<meta name="tags" content="Basics" />
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="..">Guillaume Redoulès</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse" id="searchbar">
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="../pages/about.html">About Guillaume</a></li>
|
||||
<li><a href="https://github.com/redoules">GitHub</a></li>
|
||||
<li><a href="https://www.linkedin.com/in/guillaume-redoul%C3%A8s-33923860/">LinkedIn</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Data Science<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="..#Blog">Blog</a></li>
|
||||
<li><a href="..#Python">Python</a></li>
|
||||
<li><a href="..#Bash">Bash</a></li>
|
||||
<li><a href="..#SQL">SQL</a></li>
|
||||
<li><a href="..#Mathematics">Mathematics</a></li>
|
||||
<li><a href="..#Machine_Learning">Machine Learning</a></li>
|
||||
<li><a href="..#Projects">Projects</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Projects<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="https://github.com/redoules/redoules.github.io">Notes (Github)</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<!--<li class="dropdown">
|
||||
<a href="../feeds/blog.rss.xml">Blog RSS</a>
|
||||
</li>-->
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
<form class="navbar-form" action="../search.html" onsubmit="return validateForm(this.elements['q'].value);">
|
||||
<div class="form-group" style="display:inline;">
|
||||
<div class="input-group" style="display:table;">
|
||||
<span class="input-group-addon" style="width:1%;"><span class="glyphicon glyphicon-search"></span></span>
|
||||
<input class="form-control search-query" name="q" id="tipue_search_input" placeholder="e.g. scikit KNN, pandas merge" required autocomplete="off" type="text">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- end of header section -->
|
||||
<div class="container">
|
||||
<!-- <div class="alert alert-warning" role="alert">
|
||||
Did you find this page useful? Please do me a quick favor and <a href="#" class="alert-link">endorse me for data science on LinkedIn</a>.
|
||||
</div> -->
|
||||
<section id="content" class="body">
|
||||
<header>
|
||||
<h1>
|
||||
Number of edges in a Complete graph
|
||||
</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
<time class="published" datetime="2018-11-07T09:23:00+01:00">
|
||||
07 novembre 2018
|
||||
</time>
|
||||
</li>
|
||||
<li>Mathematics</li>
|
||||
<li>Basics</li>
|
||||
</ol>
|
||||
</header>
|
||||
<div class='article_content'>
|
||||
<p>A complete graph contains $\frac{n(n-1)}{2}$ edges where $n$ is the number of vertices (or nodes).</p>
|
||||
<p><img alt="Complete Graph" src="../images/Number_of_edges_in_a_Complete_graph/complete_graph.png"></p>
|
||||
</div>
|
||||
<aside>
|
||||
<div class="bug-reporting__panel">
|
||||
<h3>Find an error or bug? Have a suggestion?</h3>
|
||||
<p>Everything on this site is avaliable on GitHub. Head on over and <a href='https://github.com/redoules/redoules.github.io/issues/new'>submit an issue.</a> You can also message me directly by <a href='mailto:guillaume.redoules@gadz.org'>email</a>.</p>
|
||||
</div>
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<!-- start of footer section -->
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
</center>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- This jQuery line finds any span that contains code highlighting classes and then selects the parent <pre> tag and adds a border. This is done as a workaround to visually distinguish the code inputs and outputs -->
|
||||
<script>
|
||||
$( ".hll, .n, .c, .err, .k, .o, .cm, .cp, .c1, .cs, .gd, .ge, .gr, .gh, .gi, .go, .gp, .gs, .gu, .gt, .kc, .kd, .kn, .kp, .kr, .kt, .m, .s, .na, .nb, .nc, .no, .nd, .ni, .ne, .nf, .nl, .nn, .nt, .nv, .ow, .w, .mf, .mh, .mi, .mo, .sb, .sc, .sd, .s2, .se, .sh, .si, .sx, .sr, .s1, .ss, .bp, .vc, .vg, .vi, .il" ).parent( "pre" ).css( "border", "1px solid #DEDEDE" );
|
||||
</script>
|
||||
|
||||
|
||||
<!-- Load Google Analytics -->
|
||||
<script>
|
||||
/*
|
||||
(function(i, s, o, g, r, a, m) {
|
||||
i['GoogleAnalyticsObject'] = r;
|
||||
i[r] = i[r] || function() {
|
||||
(i[r].q = i[r].q || []).push(arguments)
|
||||
}, i[r].l = 1 * new Date();
|
||||
a = s.createElement(o),
|
||||
m = s.getElementsByTagName(o)[0];
|
||||
a.async = 1;
|
||||
a.src = g;
|
||||
m.parentNode.insertBefore(a, m)
|
||||
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
||||
|
||||
ga('create', 'UA-66582-32', 'auto');
|
||||
ga('send', 'pageview');
|
||||
*/
|
||||
</script>
|
||||
<!-- End of Google Analytics -->
|
||||
|
||||
<!-- Bootstrap core JavaScript
|
||||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<script src="../theme/js/bootstrap.min.js"></script>
|
||||
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
||||
<script src="../theme/js/ie10-viewport-bug-workaround.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -145,7 +145,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -192,7 +192,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -241,7 +241,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -235,7 +235,7 @@ At line 5 there is a plum which is purple and contains 28 kcal
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -378,7 +378,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -168,7 +168,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -192,7 +192,7 @@ If you try to open a non existing file in read mode 'r', a FileNotFoundError wil
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -176,7 +176,7 @@ conda install numpy --channel intel --override-channels
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -237,7 +237,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -186,7 +186,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -171,7 +171,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -339,7 +339,7 @@ However, exporting to a sql database can prove very useful. Indeed, having a wel
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -338,7 +338,7 @@ http://127.0.0.1:8787/status</p>
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -148,7 +148,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -232,7 +232,7 @@ The list of dependencies required to test, build and generate the doc are listed
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -218,7 +218,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -177,7 +177,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -213,7 +213,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -248,7 +248,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
222
python/reverse.html
Normal file
222
python/reverse.html
Normal file
@ -0,0 +1,222 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
||||
<meta name="description" content="Data Science for Political and Social Phenomena">
|
||||
<meta name="author" content="Guillaume Redoulès">
|
||||
<link rel="icon" href="../favicon.ico">
|
||||
|
||||
<title>Reverse an array - Python</title>
|
||||
|
||||
<!-- JQuery -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
|
||||
<script>
|
||||
window.jQuery || document.write('<script src="../theme/js/jquery.min.js"><\/script>')
|
||||
</script>
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link rel="stylesheet" href="../theme/css/bootstrap.css" />
|
||||
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/ie10-viewport-bug-workaround.css" />
|
||||
<!-- Custom styles for this template -->
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/notebooks.css" />
|
||||
<link href='https://fonts.googleapis.com/css?family=PT+Serif:400,700|Roboto:400,500,700' rel='stylesheet' type='text/css'>
|
||||
|
||||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
<meta name="tags" content="Basics" />
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="..">Guillaume Redoulès</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse" id="searchbar">
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="../pages/about.html">About Guillaume</a></li>
|
||||
<li><a href="https://github.com/redoules">GitHub</a></li>
|
||||
<li><a href="https://www.linkedin.com/in/guillaume-redoul%C3%A8s-33923860/">LinkedIn</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Data Science<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="..#Blog">Blog</a></li>
|
||||
<li><a href="..#Python">Python</a></li>
|
||||
<li><a href="..#Bash">Bash</a></li>
|
||||
<li><a href="..#SQL">SQL</a></li>
|
||||
<li><a href="..#Mathematics">Mathematics</a></li>
|
||||
<li><a href="..#Machine_Learning">Machine Learning</a></li>
|
||||
<li><a href="..#Projects">Projects</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Projects<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="https://github.com/redoules/redoules.github.io">Notes (Github)</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<!--<li class="dropdown">
|
||||
<a href="../feeds/blog.rss.xml">Blog RSS</a>
|
||||
</li>-->
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
<form class="navbar-form" action="../search.html" onsubmit="return validateForm(this.elements['q'].value);">
|
||||
<div class="form-group" style="display:inline;">
|
||||
<div class="input-group" style="display:table;">
|
||||
<span class="input-group-addon" style="width:1%;"><span class="glyphicon glyphicon-search"></span></span>
|
||||
<input class="form-control search-query" name="q" id="tipue_search_input" placeholder="e.g. scikit KNN, pandas merge" required autocomplete="off" type="text">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- end of header section -->
|
||||
<div class="container">
|
||||
<!-- <div class="alert alert-warning" role="alert">
|
||||
Did you find this page useful? Please do me a quick favor and <a href="#" class="alert-link">endorse me for data science on LinkedIn</a>.
|
||||
</div> -->
|
||||
<section id="content" class="body">
|
||||
<header>
|
||||
<h1>
|
||||
Reverse an array
|
||||
</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
<time class="published" datetime="2018-11-07T09:00:00+01:00">
|
||||
07 novembre 2018
|
||||
</time>
|
||||
</li>
|
||||
<li>Python</li>
|
||||
<li>Basics</li>
|
||||
</ol>
|
||||
</header>
|
||||
<div class='article_content'>
|
||||
<h2>Using lists</h2>
|
||||
<p>Python provides an iterator to reverse an array <a href="https://www.python.org/dev/peps/pep-0322/">reversed()</a></p>
|
||||
<p>you can use it this way :</p>
|
||||
<div class="highlight"><pre><span></span><span class="n">arr</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="mi">5</span><span class="p">))</span>
|
||||
<span class="k">print</span><span class="p">(</span><span class="n">f</span><span class="s1">'Initial array : {arr}</span><span class="se">\n</span><span class="s1">'</span><span class="p">)</span>
|
||||
|
||||
|
||||
<span class="n">reversed_arr</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">reversed</span><span class="p">(</span><span class="n">arr</span><span class="p">))</span>
|
||||
<span class="k">print</span><span class="p">(</span><span class="n">f</span><span class="s1">'Reversed array : {reversed_arr}'</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div class="highlight"><pre><span></span>Initial array : [0, 1, 2, 3, 4]
|
||||
|
||||
Reversed array : [4, 3, 2, 1, 0]
|
||||
</pre></div>
|
||||
|
||||
|
||||
<h2>Using numpy</h2>
|
||||
<p>If you are using numpy you can reverse an array by creating a view on the array:</p>
|
||||
<div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span>
|
||||
<span class="n">arr</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
|
||||
<span class="k">print</span><span class="p">(</span><span class="n">f</span><span class="s1">'Initial array : {arr}</span><span class="se">\n</span><span class="s1">'</span><span class="p">)</span>
|
||||
|
||||
|
||||
<span class="n">reversed_arr</span> <span class="o">=</span> <span class="n">arr</span><span class="p">[::</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">print</span><span class="p">(</span><span class="n">f</span><span class="s1">'Reversed array : {reversed_arr}'</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div class="highlight"><pre><span></span>Initial array : [0 1 2 3 4]
|
||||
|
||||
Reversed array : [4 3 2 1 0]
|
||||
</pre></div>
|
||||
</div>
|
||||
<aside>
|
||||
<div class="bug-reporting__panel">
|
||||
<h3>Find an error or bug? Have a suggestion?</h3>
|
||||
<p>Everything on this site is avaliable on GitHub. Head on over and <a href='https://github.com/redoules/redoules.github.io/issues/new'>submit an issue.</a> You can also message me directly by <a href='mailto:guillaume.redoules@gadz.org'>email</a>.</p>
|
||||
</div>
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<!-- start of footer section -->
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
</center>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- This jQuery line finds any span that contains code highlighting classes and then selects the parent <pre> tag and adds a border. This is done as a workaround to visually distinguish the code inputs and outputs -->
|
||||
<script>
|
||||
$( ".hll, .n, .c, .err, .k, .o, .cm, .cp, .c1, .cs, .gd, .ge, .gr, .gh, .gi, .go, .gp, .gs, .gu, .gt, .kc, .kd, .kn, .kp, .kr, .kt, .m, .s, .na, .nb, .nc, .no, .nd, .ni, .ne, .nf, .nl, .nn, .nt, .nv, .ow, .w, .mf, .mh, .mi, .mo, .sb, .sc, .sd, .s2, .se, .sh, .si, .sx, .sr, .s1, .ss, .bp, .vc, .vg, .vi, .il" ).parent( "pre" ).css( "border", "1px solid #DEDEDE" );
|
||||
</script>
|
||||
|
||||
|
||||
<!-- Load Google Analytics -->
|
||||
<script>
|
||||
/*
|
||||
(function(i, s, o, g, r, a, m) {
|
||||
i['GoogleAnalyticsObject'] = r;
|
||||
i[r] = i[r] || function() {
|
||||
(i[r].q = i[r].q || []).push(arguments)
|
||||
}, i[r].l = 1 * new Date();
|
||||
a = s.createElement(o),
|
||||
m = s.getElementsByTagName(o)[0];
|
||||
a.async = 1;
|
||||
a.src = g;
|
||||
m.parentNode.insertBefore(a, m)
|
||||
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
||||
|
||||
ga('create', 'UA-66582-32', 'auto');
|
||||
ga('send', 'pageview');
|
||||
*/
|
||||
</script>
|
||||
<!-- End of Google Analytics -->
|
||||
|
||||
<!-- Bootstrap core JavaScript
|
||||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<script src="../theme/js/bootstrap.min.js"></script>
|
||||
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
||||
<script src="../theme/js/ie10-viewport-bug-workaround.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -381,7 +381,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -151,7 +151,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -112,7 +112,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
23
sitemap.xml
23
sitemap.xml
@ -5,7 +5,7 @@ xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
|
||||
<url>
|
||||
<loc>redoules.github.io/</loc>
|
||||
<lastmod>2018-10-30T11:37:58-00:00</lastmod>
|
||||
<lastmod>2018-11-07T21:11:20-00:00</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
<priority>0.5</priority>
|
||||
</url>
|
||||
@ -17,6 +17,27 @@ xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<priority>0.5</priority>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>redoules.github.io/linux/simple_bash_function.html</loc>
|
||||
<lastmod>2018-11-07T09:37:00+01:00</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>0.5</priority>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>redoules.github.io/mathematics/Number_edges_Complete_graph.html</loc>
|
||||
<lastmod>2018-11-07T09:23:00+01:00</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>0.5</priority>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>redoules.github.io/python/reverse.html</loc>
|
||||
<lastmod>2018-11-07T09:00:00+01:00</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>0.5</priority>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>redoules.github.io/python/design_own_libs.html</loc>
|
||||
<lastmod>2018-10-29T20:31:00+01:00</lastmod>
|
||||
|
||||
@ -344,7 +344,7 @@ Done.
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -631,7 +631,7 @@ Done.
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -216,7 +216,7 @@ Done.
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -346,7 +346,7 @@ Done.
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 39 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 42 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user