second commit
This commit is contained in:
1 parent
6202bbfdd5
commit
77b9ebf1a6
5 files changed
+1205
-156
No files matched your search
@@ -9,3 +9,4 @@ pom.xml.asc
|
||||
/.nrepl-port
|
||||
.hgignore
|
||||
.hg/
|
||||
.ipynb_checkpoints
|
||||
@@ -7,6 +7,23 @@
|
||||
"Let's load some data. The electoral results of the 2014 election are located in a file at `resources/data/election-2014.edn`. We can use the [slurp](https://clojuredocs.org/clojure.core/slurp) function for that."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"hello world\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(println \"hello world\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
@@ -27,6 +44,35 @@
|
||||
"(def raw-data-str (slurp \"resources/data/election-2014.edn\"))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"(defproject honore-beaugrand \"0.1.0-SNAPSHOT\"\n",
|
||||
" :description \"FIXME: write description\"\n",
|
||||
" :url \"http://example.com/FIXME\"\n",
|
||||
" :license {:name \"Eclipse Public License\"\n",
|
||||
" :url \"http://www.eclipse.org/legal/epl-v10.html\"}\n",
|
||||
" :dependencies [[org.clojure/clojure \"1.9.0\"]\n",
|
||||
" [cheshire \"5.8.0\"]\n",
|
||||
" [clj-http \"2.3.0\"]]\n",
|
||||
" :plugins [[lein-jupyter \"0.1.16\"]]\n",
|
||||
" :main ^:skip-aot honore-beaugrand.core\n",
|
||||
" :target-path \"target/%s\"\n",
|
||||
" :profiles {:uberjar {:aot :all}})\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(println (slurp \"project.clj\"))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -36,7 +82,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -69,7 +115,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -78,7 +124,7 @@
|
||||
"#'user/election-result"
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -96,22 +142,62 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{:statistiques {:nbVoteValide 4232262, :isResultatsFinaux true, :nbBureauVote 21617, :partisPolitiques [{:numeroPartiPolitique 6, :nomPartiPolitique \"Parti libéral du Québec/Quebec Liberal Party\", :abreviationPartiPolitique \"P.L.Q./Q.L.P.\", :nbVoteTotal 1757071, :tauxVoteTotal 41.5161, :nbCirconscriptionsEnAvance 70, :tauxCirconscriptionsEnAvance 56.0} {:numeroPartiPolitique 8, :nomPartiPolitique \"Parti québécois\", :abreviationPartiPolitique \"P.Q.\", :nbVoteTotal 1074120, :tauxVoteTotal 25.3793, :nbCirconscriptionsEnAvance 30, :tauxCirconscriptionsEnAvance 24.0} {:numeroPartiPolitique 27, :nomPartiPolitique \"Coalition avenir Québec - L'équipe François Legault\", :abreviationPartiPolitique \"C.A.Q.-É.F.L.\", :nbVoteTotal 975607, :tauxVoteTotal 23.0517, :nbCirconscriptionsEnAvance 22, :tauxCirconscriptionsEnAvance 17.6} {:numeroPartiPolitique 11, :nomPartiPolitique \"Québec solidaire\", :abreviationPartiPolitique \"Q.S.\", :nbVoteTotal 323124, :tauxVoteTotal 7.6348, :nbCirconscriptionsEnAvance 3, :tauxCirconscriptionsEnAvance 2.4} {:numeroPartiPolitique 26, :nomPartiPolitique \"Option nationale - Pour l'indépendance du Québec\", :abreviationPartiPolitique \"O.N. - P.I.Q.\", :nbVoteTotal 30697, :tauxVoteTotal 0.7253, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 10, :nomPartiPolitique \"Parti vert du Québec/Green Party of Québec\", :abreviationPartiPolitique \"P.V.Q./G.P.Q.\", :nbVoteTotal 23163, :tauxVoteTotal 0.5473, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 22, :nomPartiPolitique \"Équipe Adrien Pouliot - Parti conservateur du Québec\", :abreviationPartiPolitique \"É.A.P. - P.C.Q.\", :nbVoteTotal 16429, :tauxVoteTotal 0.3882, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 0, :nomPartiPolitique \"Candidats indépendants/Independent candidates\", :abreviationPartiPolitique \"Ind.\", :nbVoteTotal 15361, :tauxVoteTotal 0.363, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 23, :nomPartiPolitique \"Parti nul\", :abreviationPartiPolitique \"P.N.\", :nbVoteTotal 7539, :tauxVoteTotal 0.1781, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 2, :nomPartiPolitique \"Bloc pot\", :abreviationPartiPolitique \"B.P.\", :nbVoteTotal 2690, :tauxVoteTotal 0.0636, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 7, :nomPartiPolitique \"Parti marxiste-léniniste du Québec\", :abreviationPartiPolitique \"P.M.L.Q.\", :nbVoteTotal 2016, :tauxVoteTotal 0.0476, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 28, :nomPartiPolitique \"Parti équitable\", :abreviationPartiPolitique \"P.Éq.\", :nbVoteTotal 1645, :tauxVoteTotal 0.0389, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 31, :nomPartiPolitique \"Parti des sans parti\", :abreviationPartiPolitique \"P.S.P.\", :nbVoteTotal 1291, :tauxVoteTotal 0.0305, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 33, :nomPartiPolitique \"Mon pays le Québec\", :abreviationPartiPolitique \"M.P.Q.\", :nbVoteTotal 521, :tauxVoteTotal 0.0123, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 29, :nomPartiPolitique \"Équipe autonomiste\", :abreviationPartiPolitique \"É.A.\", :nbVoteTotal 400, :tauxVoteTotal 0.0095, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 4, :nomPartiPolitique \"Parti unité nationale\", :abreviationPartiPolitique \"P.U.N.\", :nbVoteTotal 241, :tauxVoteTotal 0.0057, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 25, :nomPartiPolitique \"Québec - Révolution démocratique\", :abreviationPartiPolitique \"Q.R.D.\", :nbVoteTotal 163, :tauxVoteTotal 0.0039, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 16, :nomPartiPolitique \"Parti indépendantiste\", :abreviationPartiPolitique \"P.I.\", :nbVoteTotal 126, :tauxVoteTotal 0.003, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 32, :nomPartiPolitique \"Union citoyenne du Québec / Québec Citizens' Union\", :abreviationPartiPolitique \"U.C.Q./Q.C.U.\", :nbVoteTotal 58, :tauxVoteTotal 0.0014, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0}], :nbElecteurInscrit 6012440, :nbCirconscription 125, :nbCirconscriptionSansResultat 0, :iso8601DateMAJ \"2014-04-15T02:24:38,000-04:00\", :nbCirconscriptionAvecResultat 125, :nbVoteExerce 4295055, :tauxParticipationTotal 71.4326, :nbBureauVoteRempli 21617, :nbVoteRejete 62793, :tauxBureauVoteRempli 100.0, :tauxCirconscriptionSansResultat 0.0}, :circonscriptions [{:nbVoteValide 20626, :isResultatsFinaux true, :nbElecteurInscrit 33638, :nbBureauComplete 143, :candidats [{:nLine truncated
|
||||
"4232262"
|
||||
]
|
||||
},
|
||||
"execution_count": 6,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"election-result"
|
||||
"(:nbVoteValide (:statistiques election-result))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"4232262"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(get (get election-result :statistiques) :nbVoteValide)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"4232262"
|
||||
]
|
||||
},
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(get-in election-result [:statistiques :nbVoteValide])"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -123,80 +209,22 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 31,
|
||||
"execution_count": 32,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{:nbVoteValide 20626,\n",
|
||||
" :isResultatsFinaux true,\n",
|
||||
" :nbElecteurInscrit 33638,\n",
|
||||
" :nbBureauComplete 143,\n",
|
||||
" :candidats\n",
|
||||
" [{:numeroCandidat 436,\n",
|
||||
" :nom \"Bourgeois\",\n",
|
||||
" :prenom \"Guy\",\n",
|
||||
" :numeroPartiPolitique 6,\n",
|
||||
" :abreviationPartiPolitique \"P.L.Q./Q.L.P.\",\n",
|
||||
" :nbVoteTotal 8476,\n",
|
||||
" :tauxVote 41.09,\n",
|
||||
" :nbVoteAvance 2159}\n",
|
||||
" {:numeroCandidat 694,\n",
|
||||
" :nom \"Larouche\",\n",
|
||||
" :prenom \"Élizabeth\",\n",
|
||||
" :numeroPartiPolitique 8,\n",
|
||||
" :abreviationPartiPolitique \"P.Q.\",\n",
|
||||
" :nbVoteTotal 6317,\n",
|
||||
" :tauxVote 30.63,\n",
|
||||
" :nbVoteAvance 0}\n",
|
||||
" {:numeroCandidat 690,\n",
|
||||
" :nom \"Martel\",\n",
|
||||
" :prenom \"Sylvain\",\n",
|
||||
" :numeroPartiPolitique 27,\n",
|
||||
" :abreviationPartiPolitique \"C.A.Q.-É.F.L.\",\n",
|
||||
" :nbVoteTotal 3927,\n",
|
||||
" :tauxVote 19.04,\n",
|
||||
" :nbVoteAvance 0}\n",
|
||||
" {:numeroCandidat 582,\n",
|
||||
" :nom \"Dufour\",\n",
|
||||
" :prenom \"Valérie\",\n",
|
||||
" :numeroPartiPolitique 11,\n",
|
||||
" :abreviationPartiPolitique \"Q.S.\",\n",
|
||||
" :nbVoteTotal 1469,\n",
|
||||
" :tauxVote 7.12,\n",
|
||||
" :nbVoteAvance 0}\n",
|
||||
" {:numeroCandidat 786,\n",
|
||||
" :nom \"Trudel\",\n",
|
||||
" :prenom \"Richard\",\n",
|
||||
" :numeroPartiPolitique 26,\n",
|
||||
" :abreviationPartiPolitique \"O.N. - P.I.Q.\",\n",
|
||||
" :nbVoteTotal 235,\n",
|
||||
" :tauxVote 1.14,\n",
|
||||
" :nbVoteAvance 0}\n",
|
||||
" {:numeroCandidat 616,\n",
|
||||
" :nom \"Perron-Tellier\",\n",
|
||||
" :prenom \"Maxym\",\n",
|
||||
" :numeroPartiPolitique 22,\n",
|
||||
" :abreviationPartiPolitique \"É.A.P. - P.C.Q.\",\n",
|
||||
" :nbVoteTotal 202,\n",
|
||||
" :tauxVote 0.98,\n",
|
||||
" :nbVoteAvance 0}],\n",
|
||||
" :iso8601DateMAJ \"2014-04-15T02:24:38,653-04:00\",\n",
|
||||
" :tauxVoteRejete 2.48,\n",
|
||||
" :nbVoteExerce 21151,\n",
|
||||
" :nbBureauTotal 143,\n",
|
||||
" :numeroCirconscription 579,\n",
|
||||
" :nbVoteRejete 525,\n",
|
||||
" :tauxParticipation 62.88,\n",
|
||||
" :tauxVoteValide 97.52,\n",
|
||||
" :nomCirconscription \"Abitibi-Est\"}\n"
|
||||
]
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"20626"
|
||||
]
|
||||
},
|
||||
"execution_count": 32,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(clojure.pprint/pprint (first (:circonscriptions election-result)))"
|
||||
"(:nbVoteValide (get (:circonscriptions election-result) 0))"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -208,7 +236,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -250,7 +278,235 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 32,
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"clojure.lang.PersistentArrayMap"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(type election-result)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"(20626 21947 34121 31588 30527 42634 30973 33774 30620 32153 38057 40794 44449 24902 42782 29606 33149 40683 35424 34735 34060 40252 37124 36019 43269 32609 41910 44625 34777 34464 29281 34744 34070 27755 22281 37382 19268 37108 31692 34765 41407 25925 33013 29064 32534 8263 36083 31248 34389 34812 37768 39425 30993 30572 29549 30678 42493 44525 33165 32723 37910 33700 38189 23626 34896 39414 37234 37457 30429 32542 34802 34511 29474 26574 28639 32670 41689 42805 42336 29098 45424 28900 29155 29613 27275 36404 27811 33870 30851 20051 38505 29971 41737 29637 34986 42124 32292 37095 39968 28025 38665 37689 40453 41576 37074 38227 27573 24541 39145 28794 33978 34791 35942 35933 39891 29773 10901 36249 42154 45348 43364 33943 25709 34837 24395)"
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
";; (:nbVoteValide (get (:circonscriptions election-result) 0))\n",
|
||||
"(def vote-valide-par-circonscription\n",
|
||||
" (map :nbVoteValide (:circonscriptions election-result)))\n",
|
||||
"vote-valide-par-circonscription"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"4232262"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(reduce + 0 vote-valide-par-circonscription)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"4232262"
|
||||
]
|
||||
},
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(apply + vote-valide-par-circonscription)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"2/3"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(/ 6 9)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"#'user/mercier"
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(def mercier (first (:circonscriptions election-result)))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{:nbVoteValide 20626, :isResultatsFinaux true, :nbElecteurInscrit 33638, :nbBureauComplete 143, :candidats [{:numeroCandidat 436, :nom \"Bourgeois\", :prenom \"Guy\", :numeroPartiPolitique 6, :abreviationPartiPolitique \"P.L.Q./Q.L.P.\", :nbVoteTotal 8476, :tauxVote 41.09, :nbVoteAvance 2159} {:numeroCandidat 694, :nom \"Larouche\", :prenom \"Élizabeth\", :numeroPartiPolitique 8, :abreviationPartiPolitique \"P.Q.\", :nbVoteTotal 6317, :tauxVote 30.63, :nbVoteAvance 0} {:numeroCandidat 690, :nom \"Martel\", :prenom \"Sylvain\", :numeroPartiPolitique 27, :abreviationPartiPolitique \"C.A.Q.-É.F.L.\", :nbVoteTotal 3927, :tauxVote 19.04, :nbVoteAvance 0} {:numeroCandidat 582, :nom \"Dufour\", :prenom \"Valérie\", :numeroPartiPolitique 11, :abreviationPartiPolitique \"Q.S.\", :nbVoteTotal 1469, :tauxVote 7.12, :nbVoteAvance 0} {:numeroCandidat 786, :nom \"Trudel\", :prenom \"Richard\", :numeroPartiPolitique 26, :abreviationPartiPolitique \"O.N. - P.I.Q.\", :nbVoteTotal 235, :tauxVote 1.14, :nbVoteAvance 0} {:numeroCandidat 616, :nom \"Perron-Tellier\", :prenom \"Maxym\", :numeroPartiPolitique 22, :abreviationPartiPolitique \"É.A.P. - P.C.Q.\", :nbVoteTotal 202, :tauxVote 0.98, :nbVoteAvance 0}], :iso8601DateMAJ \"2014-04-15T02:24:38,653-04:00\", :tauxVoteRejete 2.48, :nbVoteExerce 21151, :nbBureauTotal 143, :numeroCirconscription 579, :nbVoteRejete 525, :tauxParticipation 62.88, :tauxVoteValide 97.52, :nomCirconscription \"Abitibi-Est\"}"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"mercier"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"#'user/calculer-pourcentage-participation"
|
||||
]
|
||||
},
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(defn calculer-pourcentage-participation [circonscription] \n",
|
||||
" (let [nbVote (:nbVoteValide circonscription)\n",
|
||||
" nbInscrits (:nbElecteurInscrit circonscription)]\n",
|
||||
" (/ nbVote nbInscrits)))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"10313/16819"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(calculer-pourcentage-participation mercier)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"#'user/ratio-to-percent"
|
||||
]
|
||||
},
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(defn ratio-to-percent [ r]\n",
|
||||
" (double ( * r 100)))\n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"61.31755752422855"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(ratio-to-percent (calculer-pourcentage-participation mercier)) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -259,7 +515,7 @@
|
||||
"(1757071 1074120 975607 323124 30697 23163 16429 15361 7539 2690 2016 1645 1291 521 400 241 163 126 58)"
|
||||
]
|
||||
},
|
||||
"execution_count": 32,
|
||||
"execution_count": 24,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
|
||||
+334
-78
@@ -7,6 +7,23 @@
|
||||
"Let's load some data. The electoral results of the 2014 election are located in a file at `resources/data/election-2014.edn`. We can use the [slurp](https://clojuredocs.org/clojure.core/slurp) function for that."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"hello world\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(println \"hello world\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
@@ -27,6 +44,35 @@
|
||||
"(def raw-data-str (slurp \"resources/data/election-2014.edn\"))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"(defproject honore-beaugrand \"0.1.0-SNAPSHOT\"\n",
|
||||
" :description \"FIXME: write description\"\n",
|
||||
" :url \"http://example.com/FIXME\"\n",
|
||||
" :license {:name \"Eclipse Public License\"\n",
|
||||
" :url \"http://www.eclipse.org/legal/epl-v10.html\"}\n",
|
||||
" :dependencies [[org.clojure/clojure \"1.9.0\"]\n",
|
||||
" [cheshire \"5.8.0\"]\n",
|
||||
" [clj-http \"2.3.0\"]]\n",
|
||||
" :plugins [[lein-jupyter \"0.1.16\"]]\n",
|
||||
" :main ^:skip-aot honore-beaugrand.core\n",
|
||||
" :target-path \"target/%s\"\n",
|
||||
" :profiles {:uberjar {:aot :all}})\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(println (slurp \"project.clj\"))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -36,7 +82,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -69,7 +115,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -78,7 +124,7 @@
|
||||
"#'user/election-result"
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -96,22 +142,62 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{:statistiques {:nbVoteValide 4232262, :isResultatsFinaux true, :nbBureauVote 21617, :partisPolitiques [{:numeroPartiPolitique 6, :nomPartiPolitique \"Parti libéral du Québec/Quebec Liberal Party\", :abreviationPartiPolitique \"P.L.Q./Q.L.P.\", :nbVoteTotal 1757071, :tauxVoteTotal 41.5161, :nbCirconscriptionsEnAvance 70, :tauxCirconscriptionsEnAvance 56.0} {:numeroPartiPolitique 8, :nomPartiPolitique \"Parti québécois\", :abreviationPartiPolitique \"P.Q.\", :nbVoteTotal 1074120, :tauxVoteTotal 25.3793, :nbCirconscriptionsEnAvance 30, :tauxCirconscriptionsEnAvance 24.0} {:numeroPartiPolitique 27, :nomPartiPolitique \"Coalition avenir Québec - L'équipe François Legault\", :abreviationPartiPolitique \"C.A.Q.-É.F.L.\", :nbVoteTotal 975607, :tauxVoteTotal 23.0517, :nbCirconscriptionsEnAvance 22, :tauxCirconscriptionsEnAvance 17.6} {:numeroPartiPolitique 11, :nomPartiPolitique \"Québec solidaire\", :abreviationPartiPolitique \"Q.S.\", :nbVoteTotal 323124, :tauxVoteTotal 7.6348, :nbCirconscriptionsEnAvance 3, :tauxCirconscriptionsEnAvance 2.4} {:numeroPartiPolitique 26, :nomPartiPolitique \"Option nationale - Pour l'indépendance du Québec\", :abreviationPartiPolitique \"O.N. - P.I.Q.\", :nbVoteTotal 30697, :tauxVoteTotal 0.7253, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 10, :nomPartiPolitique \"Parti vert du Québec/Green Party of Québec\", :abreviationPartiPolitique \"P.V.Q./G.P.Q.\", :nbVoteTotal 23163, :tauxVoteTotal 0.5473, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 22, :nomPartiPolitique \"Équipe Adrien Pouliot - Parti conservateur du Québec\", :abreviationPartiPolitique \"É.A.P. - P.C.Q.\", :nbVoteTotal 16429, :tauxVoteTotal 0.3882, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 0, :nomPartiPolitique \"Candidats indépendants/Independent candidates\", :abreviationPartiPolitique \"Ind.\", :nbVoteTotal 15361, :tauxVoteTotal 0.363, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 23, :nomPartiPolitique \"Parti nul\", :abreviationPartiPolitique \"P.N.\", :nbVoteTotal 7539, :tauxVoteTotal 0.1781, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 2, :nomPartiPolitique \"Bloc pot\", :abreviationPartiPolitique \"B.P.\", :nbVoteTotal 2690, :tauxVoteTotal 0.0636, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 7, :nomPartiPolitique \"Parti marxiste-léniniste du Québec\", :abreviationPartiPolitique \"P.M.L.Q.\", :nbVoteTotal 2016, :tauxVoteTotal 0.0476, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 28, :nomPartiPolitique \"Parti équitable\", :abreviationPartiPolitique \"P.Éq.\", :nbVoteTotal 1645, :tauxVoteTotal 0.0389, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 31, :nomPartiPolitique \"Parti des sans parti\", :abreviationPartiPolitique \"P.S.P.\", :nbVoteTotal 1291, :tauxVoteTotal 0.0305, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 33, :nomPartiPolitique \"Mon pays le Québec\", :abreviationPartiPolitique \"M.P.Q.\", :nbVoteTotal 521, :tauxVoteTotal 0.0123, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 29, :nomPartiPolitique \"Équipe autonomiste\", :abreviationPartiPolitique \"É.A.\", :nbVoteTotal 400, :tauxVoteTotal 0.0095, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 4, :nomPartiPolitique \"Parti unité nationale\", :abreviationPartiPolitique \"P.U.N.\", :nbVoteTotal 241, :tauxVoteTotal 0.0057, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 25, :nomPartiPolitique \"Québec - Révolution démocratique\", :abreviationPartiPolitique \"Q.R.D.\", :nbVoteTotal 163, :tauxVoteTotal 0.0039, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 16, :nomPartiPolitique \"Parti indépendantiste\", :abreviationPartiPolitique \"P.I.\", :nbVoteTotal 126, :tauxVoteTotal 0.003, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0} {:numeroPartiPolitique 32, :nomPartiPolitique \"Union citoyenne du Québec / Québec Citizens' Union\", :abreviationPartiPolitique \"U.C.Q./Q.C.U.\", :nbVoteTotal 58, :tauxVoteTotal 0.0014, :nbCirconscriptionsEnAvance 0, :tauxCirconscriptionsEnAvance 0.0}], :nbElecteurInscrit 6012440, :nbCirconscription 125, :nbCirconscriptionSansResultat 0, :iso8601DateMAJ \"2014-04-15T02:24:38,000-04:00\", :nbCirconscriptionAvecResultat 125, :nbVoteExerce 4295055, :tauxParticipationTotal 71.4326, :nbBureauVoteRempli 21617, :nbVoteRejete 62793, :tauxBureauVoteRempli 100.0, :tauxCirconscriptionSansResultat 0.0}, :circonscriptions [{:nbVoteValide 20626, :isResultatsFinaux true, :nbElecteurInscrit 33638, :nbBureauComplete 143, :candidats [{:nLine truncated
|
||||
"4232262"
|
||||
]
|
||||
},
|
||||
"execution_count": 6,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"election-result"
|
||||
"(:nbVoteValide (:statistiques election-result))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"4232262"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(get (get election-result :statistiques) :nbVoteValide)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"4232262"
|
||||
]
|
||||
},
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(get-in election-result [:statistiques :nbVoteValide])"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -123,80 +209,22 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 31,
|
||||
"execution_count": 32,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{:nbVoteValide 20626,\n",
|
||||
" :isResultatsFinaux true,\n",
|
||||
" :nbElecteurInscrit 33638,\n",
|
||||
" :nbBureauComplete 143,\n",
|
||||
" :candidats\n",
|
||||
" [{:numeroCandidat 436,\n",
|
||||
" :nom \"Bourgeois\",\n",
|
||||
" :prenom \"Guy\",\n",
|
||||
" :numeroPartiPolitique 6,\n",
|
||||
" :abreviationPartiPolitique \"P.L.Q./Q.L.P.\",\n",
|
||||
" :nbVoteTotal 8476,\n",
|
||||
" :tauxVote 41.09,\n",
|
||||
" :nbVoteAvance 2159}\n",
|
||||
" {:numeroCandidat 694,\n",
|
||||
" :nom \"Larouche\",\n",
|
||||
" :prenom \"Élizabeth\",\n",
|
||||
" :numeroPartiPolitique 8,\n",
|
||||
" :abreviationPartiPolitique \"P.Q.\",\n",
|
||||
" :nbVoteTotal 6317,\n",
|
||||
" :tauxVote 30.63,\n",
|
||||
" :nbVoteAvance 0}\n",
|
||||
" {:numeroCandidat 690,\n",
|
||||
" :nom \"Martel\",\n",
|
||||
" :prenom \"Sylvain\",\n",
|
||||
" :numeroPartiPolitique 27,\n",
|
||||
" :abreviationPartiPolitique \"C.A.Q.-É.F.L.\",\n",
|
||||
" :nbVoteTotal 3927,\n",
|
||||
" :tauxVote 19.04,\n",
|
||||
" :nbVoteAvance 0}\n",
|
||||
" {:numeroCandidat 582,\n",
|
||||
" :nom \"Dufour\",\n",
|
||||
" :prenom \"Valérie\",\n",
|
||||
" :numeroPartiPolitique 11,\n",
|
||||
" :abreviationPartiPolitique \"Q.S.\",\n",
|
||||
" :nbVoteTotal 1469,\n",
|
||||
" :tauxVote 7.12,\n",
|
||||
" :nbVoteAvance 0}\n",
|
||||
" {:numeroCandidat 786,\n",
|
||||
" :nom \"Trudel\",\n",
|
||||
" :prenom \"Richard\",\n",
|
||||
" :numeroPartiPolitique 26,\n",
|
||||
" :abreviationPartiPolitique \"O.N. - P.I.Q.\",\n",
|
||||
" :nbVoteTotal 235,\n",
|
||||
" :tauxVote 1.14,\n",
|
||||
" :nbVoteAvance 0}\n",
|
||||
" {:numeroCandidat 616,\n",
|
||||
" :nom \"Perron-Tellier\",\n",
|
||||
" :prenom \"Maxym\",\n",
|
||||
" :numeroPartiPolitique 22,\n",
|
||||
" :abreviationPartiPolitique \"É.A.P. - P.C.Q.\",\n",
|
||||
" :nbVoteTotal 202,\n",
|
||||
" :tauxVote 0.98,\n",
|
||||
" :nbVoteAvance 0}],\n",
|
||||
" :iso8601DateMAJ \"2014-04-15T02:24:38,653-04:00\",\n",
|
||||
" :tauxVoteRejete 2.48,\n",
|
||||
" :nbVoteExerce 21151,\n",
|
||||
" :nbBureauTotal 143,\n",
|
||||
" :numeroCirconscription 579,\n",
|
||||
" :nbVoteRejete 525,\n",
|
||||
" :tauxParticipation 62.88,\n",
|
||||
" :tauxVoteValide 97.52,\n",
|
||||
" :nomCirconscription \"Abitibi-Est\"}\n"
|
||||
]
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"20626"
|
||||
]
|
||||
},
|
||||
"execution_count": 32,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(clojure.pprint/pprint (first (:circonscriptions election-result)))"
|
||||
"(:nbVoteValide (get (:circonscriptions election-result) 0))"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -208,7 +236,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -250,7 +278,235 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 32,
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"clojure.lang.PersistentArrayMap"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(type election-result)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"(20626 21947 34121 31588 30527 42634 30973 33774 30620 32153 38057 40794 44449 24902 42782 29606 33149 40683 35424 34735 34060 40252 37124 36019 43269 32609 41910 44625 34777 34464 29281 34744 34070 27755 22281 37382 19268 37108 31692 34765 41407 25925 33013 29064 32534 8263 36083 31248 34389 34812 37768 39425 30993 30572 29549 30678 42493 44525 33165 32723 37910 33700 38189 23626 34896 39414 37234 37457 30429 32542 34802 34511 29474 26574 28639 32670 41689 42805 42336 29098 45424 28900 29155 29613 27275 36404 27811 33870 30851 20051 38505 29971 41737 29637 34986 42124 32292 37095 39968 28025 38665 37689 40453 41576 37074 38227 27573 24541 39145 28794 33978 34791 35942 35933 39891 29773 10901 36249 42154 45348 43364 33943 25709 34837 24395)"
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
";; (:nbVoteValide (get (:circonscriptions election-result) 0))\n",
|
||||
"(def vote-valide-par-circonscription\n",
|
||||
" (map :nbVoteValide (:circonscriptions election-result)))\n",
|
||||
"vote-valide-par-circonscription"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"4232262"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(reduce + 0 vote-valide-par-circonscription)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"4232262"
|
||||
]
|
||||
},
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(apply + vote-valide-par-circonscription)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"2/3"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(/ 6 9)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"#'user/mercier"
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(def mercier (first (:circonscriptions election-result)))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{:nbVoteValide 20626, :isResultatsFinaux true, :nbElecteurInscrit 33638, :nbBureauComplete 143, :candidats [{:numeroCandidat 436, :nom \"Bourgeois\", :prenom \"Guy\", :numeroPartiPolitique 6, :abreviationPartiPolitique \"P.L.Q./Q.L.P.\", :nbVoteTotal 8476, :tauxVote 41.09, :nbVoteAvance 2159} {:numeroCandidat 694, :nom \"Larouche\", :prenom \"Élizabeth\", :numeroPartiPolitique 8, :abreviationPartiPolitique \"P.Q.\", :nbVoteTotal 6317, :tauxVote 30.63, :nbVoteAvance 0} {:numeroCandidat 690, :nom \"Martel\", :prenom \"Sylvain\", :numeroPartiPolitique 27, :abreviationPartiPolitique \"C.A.Q.-É.F.L.\", :nbVoteTotal 3927, :tauxVote 19.04, :nbVoteAvance 0} {:numeroCandidat 582, :nom \"Dufour\", :prenom \"Valérie\", :numeroPartiPolitique 11, :abreviationPartiPolitique \"Q.S.\", :nbVoteTotal 1469, :tauxVote 7.12, :nbVoteAvance 0} {:numeroCandidat 786, :nom \"Trudel\", :prenom \"Richard\", :numeroPartiPolitique 26, :abreviationPartiPolitique \"O.N. - P.I.Q.\", :nbVoteTotal 235, :tauxVote 1.14, :nbVoteAvance 0} {:numeroCandidat 616, :nom \"Perron-Tellier\", :prenom \"Maxym\", :numeroPartiPolitique 22, :abreviationPartiPolitique \"É.A.P. - P.C.Q.\", :nbVoteTotal 202, :tauxVote 0.98, :nbVoteAvance 0}], :iso8601DateMAJ \"2014-04-15T02:24:38,653-04:00\", :tauxVoteRejete 2.48, :nbVoteExerce 21151, :nbBureauTotal 143, :numeroCirconscription 579, :nbVoteRejete 525, :tauxParticipation 62.88, :tauxVoteValide 97.52, :nomCirconscription \"Abitibi-Est\"}"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"mercier"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"#'user/calculer-pourcentage-participation"
|
||||
]
|
||||
},
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(defn calculer-pourcentage-participation [circonscription] \n",
|
||||
" (let [nbVote (:nbVoteValide circonscription)\n",
|
||||
" nbInscrits (:nbElecteurInscrit circonscription)]\n",
|
||||
" (/ nbVote nbInscrits)))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"10313/16819"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(calculer-pourcentage-participation mercier)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"#'user/ratio-to-percent"
|
||||
]
|
||||
},
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(defn ratio-to-percent [ r]\n",
|
||||
" (double ( * r 100)))\n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"61.31755752422855"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(ratio-to-percent (calculer-pourcentage-participation mercier)) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -259,7 +515,7 @@
|
||||
"(1757071 1074120 975607 323124 30697 23163 16429 15361 7539 2690 2016 1645 1291 521 400 241 163 126 58)"
|
||||
]
|
||||
},
|
||||
"execution_count": 32,
|
||||
"execution_count": 24,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
|
||||
+270
@@ -0,0 +1,270 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"\"1232\""
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(str 12 32)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"\"1232\""
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(str \"12\" \"32\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"32.0"
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(double 32)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[1 2 3]"
|
||||
]
|
||||
},
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(vector 1 2 3)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{:age 12, :name \"Pascal\"}"
|
||||
]
|
||||
},
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(hash-map :age 12 :name \"Pascal\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"true"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"true "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"java.lang.Boolean"
|
||||
]
|
||||
},
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(type true)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"false"
|
||||
]
|
||||
},
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"false"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"java.lang.Boolean"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(type false)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
":Salut"
|
||||
]
|
||||
},
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(keyword \"Salut\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"nil"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"nil\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(println nil)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Bonjour\n",
|
||||
"bob\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(println \"Bonjour\\nbob\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Lein-Clojure",
|
||||
"language": "clojure",
|
||||
"name": "lein-clojure"
|
||||
},
|
||||
"language_info": {
|
||||
"file_extension": ".clj",
|
||||
"mimetype": "text/x-clojure",
|
||||
"name": "clojure",
|
||||
"version": "1.9.0"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
+266
@@ -0,0 +1,266 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"5"
|
||||
]
|
||||
},
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"5"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"java.lang.Long"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(type 5)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"java.lang.Double"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(type 5.7)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"\"Bonjour a tous\""
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\"Bonjour a tous\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"java.lang.String"
|
||||
]
|
||||
},
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(type \"Bonjour a tous\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
":age"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
":age"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"clojure.lang.Keyword"
|
||||
]
|
||||
},
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(type :age)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{:age 15, :name \"Pascal\"}"
|
||||
]
|
||||
},
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"{:age 15 :name \"Pascal\"}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"clojure.lang.PersistentArrayMap"
|
||||
]
|
||||
},
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(type {:age 15 :name \"Pascal\"})"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"(\"Bonjour a tous\" 12)"
|
||||
]
|
||||
},
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(list \"Bonjour a tous\" 12)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[\"Bonjour a tous\" 12]"
|
||||
]
|
||||
},
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"[\"Bonjour a tous\" 12]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[\"Bonjour a tous\" 12 \"Salut\"]"
|
||||
]
|
||||
},
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(conj [\"Bonjour a tous\" 12 ] \"Salut\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Lein-Clojure",
|
||||
"language": "clojure",
|
||||
"name": "lein-clojure"
|
||||
},
|
||||
"language_info": {
|
||||
"file_extension": ".clj",
|
||||
"mimetype": "text/x-clojure",
|
||||
"name": "clojure",
|
||||
"version": "1.9.0"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
Reference in new issue
Block a user