├── .gitignore
├── README.md
├── code_examples
├── clj-example.clj
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── doc
│ │ └── intro.md
│ ├── project.clj
│ ├── resources
│ │ └── data.csv
│ ├── src
│ │ └── clj_example
│ │ │ └── clj.clj
│ └── test
│ │ └── clj_example
│ │ └── clj_test.clj
├── data.csv
├── example.py
└── example_functional.py
├── img
├── (.png
├── clj-def-fn.png
├── clj-defn.png
├── clj-example.png
├── clj-map.png
├── clj_conj.png
├── clj_def.png
├── clj_list.png
├── clj_map.png
├── clj_set.png
├── clj_vector.png
├── lein_new.png
├── lein_repl.png
├── lein_run.png
├── lein_test.png
├── lein_uberjar.png
├── lisp_cycles.png
├── python-fun-lambda.png
├── python-iter.png
├── python-lambda.png
├── python_example.png
├── python_fun_ex.png
├── python_lc.png
└── python_tuple.png
├── python_to_clojure.odp
└── python_to_clojure.pdf
/.gitignore:
--------------------------------------------------------------------------------
1 | *.*~
2 | *#
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | FROM PYTHON TO CLOJURE
2 | =======
3 |
4 | Resources + tools for pythonistas interested in Clojure and FP
5 | -------
6 |
7 | ###Refs from the poster
8 |
9 | ####References:
10 |
11 | 1. [Leiningen](http://leiningen.org)
12 | 2. [4 clojure](http://4clojure.com)
13 | 3. [Clojure Koans](http://clojurekoans.com)
14 | 4. [Clojurescript Koans](http://clojurescriptkoans.com)
15 | 5. [Clojure katas](http://github.com/gigasquid/wonderland-clojure-katas)
16 | 6. [ClojureBridge](http://clojurebridge.org)
17 |
18 |
19 | ####Other resources:
20 |
21 | * [Clojure docs](http://clojuredocs.org)
22 | * [More on Java](http://www.flyingmachinestudios.com/programming/how-clojure-babies-are-made-the-java-cycle/)
23 | * [More on Leiningen](http://www.flyingmachinestudios.com/programming/how-clojure-babies-are-made-what-leiningen-is/)
24 | * [Imperative vs functional](https://joshldavis.com/2013/09/30/difference-between-imperative-and-functional-part-1/)
25 | * [Python to Clojure](http://zachcp.org/blog/2015/python-to-clojure/)
26 |
27 |
28 | ###CLOJURE
29 |
30 | ####Learning the language and concepts:
31 | * [The beauty of Clojure](http://owenrh.me.uk/blog/2015/08/24/)
32 | * [ClojureBridge docs](http://clojurebridge.github.io/community-docs/index.html)
33 | * [Clojure for the Brave and True](http://www.braveclojure.com)
34 | * [Programming to abstractions](http://www.braveclojure.com/core-functions-in-depth/#1__Programming_to_Abstractions)
35 | * [Destructuring](http://blog.jayfields.com/2010/07/clojure-destructuring.html)
36 | * [Lazy sequences](http://www.braveclojure.com/core-functions-in-depth/#2_3__Lazy_Seqs)
37 | * [On concurrency and parallel programming](http://www.braveclojure.com/concurrency/)
38 | * [ClojureScript: Clojure to JS](https://github.com/clojure/clojurescript)
39 |
40 |
41 | ####Tools and libraries:
42 | * [Clojure toolbox](http://www.clojure-toolbox.com/)
43 |
44 | ####EMACS related:
45 | * [Emacs Clojure Mode](https://github.com/clojure-emacs/clojure-mode)
46 | * [Emacs CIDER repl](https://github.com/clojure-emacs/cider)
47 | * [HTML with Clojure: Hiccup](https://github.com/weavejester/hiccup)
48 |
49 | ####Other text editors:
50 | * [Clojure in Vim](http://www.neo.com/2014/02/25/getting-started-with-clojure-in-vim)
51 | * [LightTable](http://lighttable.com/)
52 | * [Cursive](https://cursiveclojure.com/)
53 | * [NightCode](https://sekao.net/nightcode/)
54 |
55 | ####Notebooks:
56 | * [Gorilla repl](http://gorilla-repl.org/index.html)
57 | * [Jupyter Clojure kernel](https://github.com/roryk/ipython-clojure)
58 | * [Beaker notebook](http://beakernotebook.com/index)
59 |
60 |
61 | ###PYTHON
62 |
63 | ####Functional programming in Python:
64 | * [Functional programming HOWTO (Python 2)](http://docs.python.org/2/howto/functional.html)
65 | * [Python practice book](http://anandology.com/python-practice-book/functional-programming.html)
66 | * [Python functional tutorial](http://thenewcircle.com/static/bookshelf/python_fundamentals_tutorial/functional_programming.html)
67 | * [Functional programming modules (Python 3)](http://docs.python.org/3/library/functional.html)
68 | * [Fn.py: library with extra FP capabilities](https://github.com/kachayev/fn.py)
69 | * [Pyrsistent: immutable data structures](http://pypi.python.org/pypi/pyrsistent/)
70 |
71 | ####Hy: Lisp-like Python dialect (with a cute mascot)
72 | * [Hy's docs](http://docs.hylang.org/en/latest/)
73 | * [Jupyter Hy kernel](https://github.com/bollwyvl/hy_kernel/)
74 |
75 |
76 |
77 |
78 | ------------------
79 |
80 |
81 | 
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
82 |
--------------------------------------------------------------------------------
/code_examples/clj-example.clj/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | /classes
3 | /checkouts
4 | pom.xml
5 | pom.xml.asc
6 | *.jar
7 | *.class
8 | /.lein-*
9 | /.nrepl-port
10 |
--------------------------------------------------------------------------------
/code_examples/clj-example.clj/LICENSE:
--------------------------------------------------------------------------------
1 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
2 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
3 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
4 |
5 | 1. DEFINITIONS
6 |
7 | "Contribution" means:
8 |
9 | a) in the case of the initial Contributor, the initial code and
10 | documentation distributed under this Agreement, and
11 |
12 | b) in the case of each subsequent Contributor:
13 |
14 | i) changes to the Program, and
15 |
16 | ii) additions to the Program;
17 |
18 | where such changes and/or additions to the Program originate from and are
19 | distributed by that particular Contributor. A Contribution 'originates' from
20 | a Contributor if it was added to the Program by such Contributor itself or
21 | anyone acting on such Contributor's behalf. Contributions do not include
22 | additions to the Program which: (i) are separate modules of software
23 | distributed in conjunction with the Program under their own license
24 | agreement, and (ii) are not derivative works of the Program.
25 |
26 | "Contributor" means any person or entity that distributes the Program.
27 |
28 | "Licensed Patents" mean patent claims licensable by a Contributor which are
29 | necessarily infringed by the use or sale of its Contribution alone or when
30 | combined with the Program.
31 |
32 | "Program" means the Contributions distributed in accordance with this
33 | Agreement.
34 |
35 | "Recipient" means anyone who receives the Program under this Agreement,
36 | including all Contributors.
37 |
38 | 2. GRANT OF RIGHTS
39 |
40 | a) Subject to the terms of this Agreement, each Contributor hereby grants
41 | Recipient a non-exclusive, worldwide, royalty-free copyright license to
42 | reproduce, prepare derivative works of, publicly display, publicly perform,
43 | distribute and sublicense the Contribution of such Contributor, if any, and
44 | such derivative works, in source code and object code form.
45 |
46 | b) Subject to the terms of this Agreement, each Contributor hereby grants
47 | Recipient a non-exclusive, worldwide, royalty-free patent license under
48 | Licensed Patents to make, use, sell, offer to sell, import and otherwise
49 | transfer the Contribution of such Contributor, if any, in source code and
50 | object code form. This patent license shall apply to the combination of the
51 | Contribution and the Program if, at the time the Contribution is added by the
52 | Contributor, such addition of the Contribution causes such combination to be
53 | covered by the Licensed Patents. The patent license shall not apply to any
54 | other combinations which include the Contribution. No hardware per se is
55 | licensed hereunder.
56 |
57 | c) Recipient understands that although each Contributor grants the licenses
58 | to its Contributions set forth herein, no assurances are provided by any
59 | Contributor that the Program does not infringe the patent or other
60 | intellectual property rights of any other entity. Each Contributor disclaims
61 | any liability to Recipient for claims brought by any other entity based on
62 | infringement of intellectual property rights or otherwise. As a condition to
63 | exercising the rights and licenses granted hereunder, each Recipient hereby
64 | assumes sole responsibility to secure any other intellectual property rights
65 | needed, if any. For example, if a third party patent license is required to
66 | allow Recipient to distribute the Program, it is Recipient's responsibility
67 | to acquire that license before distributing the Program.
68 |
69 | d) Each Contributor represents that to its knowledge it has sufficient
70 | copyright rights in its Contribution, if any, to grant the copyright license
71 | set forth in this Agreement.
72 |
73 | 3. REQUIREMENTS
74 |
75 | A Contributor may choose to distribute the Program in object code form under
76 | its own license agreement, provided that:
77 |
78 | a) it complies with the terms and conditions of this Agreement; and
79 |
80 | b) its license agreement:
81 |
82 | i) effectively disclaims on behalf of all Contributors all warranties and
83 | conditions, express and implied, including warranties or conditions of title
84 | and non-infringement, and implied warranties or conditions of merchantability
85 | and fitness for a particular purpose;
86 |
87 | ii) effectively excludes on behalf of all Contributors all liability for
88 | damages, including direct, indirect, special, incidental and consequential
89 | damages, such as lost profits;
90 |
91 | iii) states that any provisions which differ from this Agreement are offered
92 | by that Contributor alone and not by any other party; and
93 |
94 | iv) states that source code for the Program is available from such
95 | Contributor, and informs licensees how to obtain it in a reasonable manner on
96 | or through a medium customarily used for software exchange.
97 |
98 | When the Program is made available in source code form:
99 |
100 | a) it must be made available under this Agreement; and
101 |
102 | b) a copy of this Agreement must be included with each copy of the Program.
103 |
104 | Contributors may not remove or alter any copyright notices contained within
105 | the Program.
106 |
107 | Each Contributor must identify itself as the originator of its Contribution,
108 | if any, in a manner that reasonably allows subsequent Recipients to identify
109 | the originator of the Contribution.
110 |
111 | 4. COMMERCIAL DISTRIBUTION
112 |
113 | Commercial distributors of software may accept certain responsibilities with
114 | respect to end users, business partners and the like. While this license is
115 | intended to facilitate the commercial use of the Program, the Contributor who
116 | includes the Program in a commercial product offering should do so in a
117 | manner which does not create potential liability for other Contributors.
118 | Therefore, if a Contributor includes the Program in a commercial product
119 | offering, such Contributor ("Commercial Contributor") hereby agrees to defend
120 | and indemnify every other Contributor ("Indemnified Contributor") against any
121 | losses, damages and costs (collectively "Losses") arising from claims,
122 | lawsuits and other legal actions brought by a third party against the
123 | Indemnified Contributor to the extent caused by the acts or omissions of such
124 | Commercial Contributor in connection with its distribution of the Program in
125 | a commercial product offering. The obligations in this section do not apply
126 | to any claims or Losses relating to any actual or alleged intellectual
127 | property infringement. In order to qualify, an Indemnified Contributor must:
128 | a) promptly notify the Commercial Contributor in writing of such claim, and
129 | b) allow the Commercial Contributor tocontrol, and cooperate with the
130 | Commercial Contributor in, the defense and any related settlement
131 | negotiations. The Indemnified Contributor may participate in any such claim
132 | at its own expense.
133 |
134 | For example, a Contributor might include the Program in a commercial product
135 | offering, Product X. That Contributor is then a Commercial Contributor. If
136 | that Commercial Contributor then makes performance claims, or offers
137 | warranties related to Product X, those performance claims and warranties are
138 | such Commercial Contributor's responsibility alone. Under this section, the
139 | Commercial Contributor would have to defend claims against the other
140 | Contributors related to those performance claims and warranties, and if a
141 | court requires any other Contributor to pay any damages as a result, the
142 | Commercial Contributor must pay those damages.
143 |
144 | 5. NO WARRANTY
145 |
146 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON
147 | AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER
148 | EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR
149 | CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A
150 | PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the
151 | appropriateness of using and distributing the Program and assumes all risks
152 | associated with its exercise of rights under this Agreement , including but
153 | not limited to the risks and costs of program errors, compliance with
154 | applicable laws, damage to or loss of data, programs or equipment, and
155 | unavailability or interruption of operations.
156 |
157 | 6. DISCLAIMER OF LIABILITY
158 |
159 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
160 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
161 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION
162 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
163 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
164 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
165 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY
166 | OF SUCH DAMAGES.
167 |
168 | 7. GENERAL
169 |
170 | If any provision of this Agreement is invalid or unenforceable under
171 | applicable law, it shall not affect the validity or enforceability of the
172 | remainder of the terms of this Agreement, and without further action by the
173 | parties hereto, such provision shall be reformed to the minimum extent
174 | necessary to make such provision valid and enforceable.
175 |
176 | If Recipient institutes patent litigation against any entity (including a
177 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself
178 | (excluding combinations of the Program with other software or hardware)
179 | infringes such Recipient's patent(s), then such Recipient's rights granted
180 | under Section 2(b) shall terminate as of the date such litigation is filed.
181 |
182 | All Recipient's rights under this Agreement shall terminate if it fails to
183 | comply with any of the material terms or conditions of this Agreement and
184 | does not cure such failure in a reasonable period of time after becoming
185 | aware of such noncompliance. If all Recipient's rights under this Agreement
186 | terminate, Recipient agrees to cease use and distribution of the Program as
187 | soon as reasonably practicable. However, Recipient's obligations under this
188 | Agreement and any licenses granted by Recipient relating to the Program shall
189 | continue and survive.
190 |
191 | Everyone is permitted to copy and distribute copies of this Agreement, but in
192 | order to avoid inconsistency the Agreement is copyrighted and may only be
193 | modified in the following manner. The Agreement Steward reserves the right to
194 | publish new versions (including revisions) of this Agreement from time to
195 | time. No one other than the Agreement Steward has the right to modify this
196 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The
197 | Eclipse Foundation may assign the responsibility to serve as the Agreement
198 | Steward to a suitable separate entity. Each new version of the Agreement will
199 | be given a distinguishing version number. The Program (including
200 | Contributions) may always be distributed subject to the version of the
201 | Agreement under which it was received. In addition, after a new version of
202 | the Agreement is published, Contributor may elect to distribute the Program
203 | (including its Contributions) under the new version. Except as expressly
204 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or
205 | licenses to the intellectual property of any Contributor under this
206 | Agreement, whether expressly, by implication, estoppel or otherwise. All
207 | rights in the Program not expressly granted under this Agreement are
208 | reserved.
209 |
210 | This Agreement is governed by the laws of the State of New York and the
211 | intellectual property laws of the United States of America. No party to this
212 | Agreement will bring a legal action under this Agreement more than one year
213 | after the cause of action arose. Each party waives its rights to a jury trial
214 | in any resulting litigation.
215 |
--------------------------------------------------------------------------------
/code_examples/clj-example.clj/README.md:
--------------------------------------------------------------------------------
1 | # clj-example.clj
2 |
3 | FIXME: description
4 |
5 | ## Installation
6 |
7 | Download from http://example.com/FIXME.
8 |
9 | ## Usage
10 |
11 | FIXME: explanation
12 |
13 | $ java -jar clj-example.clj-0.1.0-standalone.jar [args]
14 |
15 | ## Options
16 |
17 | FIXME: listing of options this app accepts.
18 |
19 | ## Examples
20 |
21 | ...
22 |
23 | ### Bugs
24 |
25 | ...
26 |
27 | ### Any Other Sections
28 | ### That You Think
29 | ### Might be Useful
30 |
31 | ## License
32 |
33 | Copyright © 2015 FIXME
34 |
35 | Distributed under the Eclipse Public License either version 1.0 or (at
36 | your option) any later version.
37 |
--------------------------------------------------------------------------------
/code_examples/clj-example.clj/doc/intro.md:
--------------------------------------------------------------------------------
1 | # Introduction to clj-example.clj
2 |
3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/)
4 |
--------------------------------------------------------------------------------
/code_examples/clj-example.clj/project.clj:
--------------------------------------------------------------------------------
1 | (defproject clj-example.clj "0.1.0-SNAPSHOT"
2 | :description "FIXME: write description"
3 | :url "http://example.com/FIXME"
4 | :license {:name "Eclipse Public License"
5 | :url "http://www.eclipse.org/legal/epl-v10.html"}
6 | :dependencies [[org.clojure/clojure "1.6.0"]]
7 | :main ^:skip-aot clj-example.clj
8 | :target-path "target/%s"
9 | :profiles {:uberjar {:aot :all}})
10 |
--------------------------------------------------------------------------------
/code_examples/clj-example.clj/resources/data.csv:
--------------------------------------------------------------------------------
1 | continent,Country iso,Country name,disaster subgroup,occurrence,Total deaths,Affected,Injured,Homeless,Total affected,Total damage
2 | Africa,DZA,Algeria,Geophysical,1,6,0,420,0,420,0
3 | Africa,BFA,Burkina Faso,Climatological,1,0,4000000,0,0,4000000,0
4 | Africa,BDI,Burundi,Hydrological,1,96,0,182,12500,12682,0
5 | Africa,CMR,Cameroon,Biological,1,77,1680,0,0,1680,0
6 | Africa,CMR,Cameroon,Hydrological,1,0,2120,0,1380,3500,0
7 | Africa,CPV,Cape Verde Is,Geophysical,1,0,980,0,0,980,0
8 | Africa,COM,Comoros,Geophysical,1,0,10000,0,0,10000,0
9 | Africa,COM,Comoros,Meteorological,1,0,9511,0,0,9511,0
10 | Africa,CIV,Cote d'Ivoire,Hydrological,1,39,0,0,0,0,0
11 | Africa,GMB,Gambia The,Biological,1,0,0,0,0,0,0
12 | Africa,GHA,Ghana,Biological,1,214,26858,0,0,26858,0
13 | Africa,GIN,Guinea,Biological,1,1871,2868,0,0,2868,0
14 | Africa,KEN,Kenya,Climatological,1,0,1600000,0,0,1600000,0
15 | Africa,LSO,Lesotho,Meteorological,1,0,0,0,2600,2600,0
16 | Africa,LBR,Liberia,Biological,1,3613,8464,0,0,8464,0
17 | Africa,MDG,Madagascar,Meteorological,1,17,0,0,1736,1736,0
18 | Africa,MWI,Malawi,Hydrological,1,0,44850,0,0,44850,0
19 | Africa,MLI,Mali,Biological,1,6,7,0,0,7,0
20 | Africa,MAR,Morocco,Hydrological,1,11,0,0,0,0,0
21 | Africa,MAR,Morocco,Meteorological,2,38,117000,0,0,117000,450000
22 | Africa,MOZ,Mozambique,Hydrological,4,22,143760,76,0,143836,0
23 | Africa,NER,Niger,Biological,2,20,5,183,0,188,0
24 | Africa,NER,Niger,Hydrological,1,36,165578,0,0,165578,0
25 | Africa,NGA,Nigeria,Biological,2,186,12244,0,0,12244,0
26 | Africa,NGA,Nigeria,Hydrological,1,15,10000,0,0,10000,0
27 | Africa,SEN,Senegal,Biological,1,0,1,0,0,1,0
28 | Africa,SYC,Seychelles,Hydrological,1,0,4435,0,0,4435,0
29 | Africa,SLE,Sierra Leone,Biological,1,3108,10273,0,0,10273,0
30 | Africa,SOM,Somalia,Climatological,1,0,350000,0,0,350000,0
31 | Africa,SOM,Somalia,Hydrological,1,0,21000,0,0,21000,0
32 | Africa,ZAF,South Africa,Geophysical,1,1,2000,2,0,2002,0
33 | Africa,ZAF,South Africa,Hydrological,1,32,7185,0,0,7185,85000
34 | Africa,SSD,South Sudan,Biological,2,149,5900,586,0,6486,0
35 | Africa,SDN,Sudan,Hydrological,1,77,260000,227,0,260227,0
36 | Africa,SWZ,Swaziland,Hydrological,1,11,400,0,0,400,0
37 | Africa,TZA,Tanzania Uni Rep,Hydrological,2,31,40000,0,0,40000,0
38 | Africa,COD,Zaire/Congo Dem Rep,Biological,1,49,0,17,0,17,0
39 | Africa,COD,Zaire/Congo Dem Rep,Hydrological,2,41,0,0,3750,3750,0
40 | Africa,ZMB,Zambia,Hydrological,1,0,0,0,20000,20000,0
41 | Africa,ZWE,Zimbabwe,Hydrological,2,14,2500,2,0,2502,20000
42 | Americas,ARG,Argentina,Hydrological,3,27,5553,0,0,5553,62000
43 | Americas,BOL,Bolivia,Climatological,1,0,51180,0,0,51180,0
44 | Americas,BOL,Bolivia,Hydrological,1,64,0,0,150000,150000,100000
45 | Americas,BRA,Brazil,Climatological,1,0,0,0,0,0,5000000
46 | Americas,BRA,Brazil,Hydrological,3,45,550600,52,0,550652,0
47 | Americas,CAN,Canada,Meteorological,1,0,0,0,0,0,0
48 | Americas,CHL,Chile,Climatological,1,12,17500,500,0,18000,34000
49 | Americas,CHL,Chile,Geophysical,2,12,1027224,0,0,1027224,200000
50 | Americas,COL,Colombia,Hydrological,4,77,54214,0,0,54214,0
51 | Americas,COL,Colombia,Meteorological,1,11,0,18,0,18,0
52 | Americas,DOM,Dominican Rep,Hydrological,1,1,300,0,0,300,0
53 | Americas,ECU,Ecuador,Geophysical,1,3,0,18,0,18,0
54 | Americas,SLV,El Salvador,Biological,2,4,12906,0,0,12906,0
55 | Americas,GTM,Guatemala,Climatological,1,0,1180000,0,0,1180000,58000
56 | Americas,GTM,Guatemala,Geophysical,1,1,53611,274,9940,63825,0
57 | Americas,GTM,Guatemala,Hydrological,1,0,0,0,0,0,0
58 | Americas,GTM,Guatemala,Meteorological,1,5,100000,0,0,100000,0
59 | Americas,HTI,Haiti,Biological,1,0,68111,0,0,68111,0
60 | Americas,HTI,Haiti,Hydrological,1,12,30000,0,0,30000,0
61 | Americas,HND,Honduras,Climatological,1,0,931555,0,0,931555,0
62 | Americas,HND,Honduras,Hydrological,2,4,23000,0,0,23000,1400
63 | Americas,JAM,Jamaica,Climatological,1,0,91545,0,0,91545,0
64 | Americas,MEX,Mexico,Geophysical,2,3,27381,0,0,27381,0
65 | Americas,MEX,Mexico,Meteorological,6,15,69000,135,0,69135,2539500
66 | Americas,NIC,Nicaragua,Geophysical,1,2,2375,266,0,2641,0
67 | Americas,NIC,Nicaragua,Hydrological,1,0,60345,0,0,60345,0
68 | Americas,PAN,Panama,Hydrological,1,9,116,0,0,116,0
69 | Americas,PRY,Paraguay,Hydrological,1,0,231360,0,0,231360,0
70 | Americas,PER,Peru,Geophysical,1,8,600,4,0,604,0
71 | Americas,PER,Peru,Hydrological,1,0,6300,0,2700,9000,0
72 | Americas,PRI,Puerto Rico,Hydrological,1,1,0,0,0,0,0
73 | Americas,USA,United States,Climatological,2,2,429,0,0,429,4100000
74 | Americas,USA,United States,Geophysical,1,1,3360,172,0,3532,1000000
75 | Americas,USA,United States,Hydrological,2,41,0,0,150,150,100000
76 | Americas,USA,United States,Meteorological,12,169,834,250,30,1114,10716000
77 | Asia,AFG,Afghanistan,Hydrological,2,512,140000,135,10000,150135,0
78 | Asia,AFG,Afghanistan,Meteorological,1,63,0,0,0,0,0
79 | Asia,BGD,Bangladesh,Hydrological,1,59,2800000,447,0,2800447,150000
80 | Asia,BGD,Bangladesh,Meteorological,2,20,6250,12,0,6262,0
81 | Asia,KHM,Cambodia,Hydrological,1,45,57950,0,0,57950,0
82 | Asia,CHN,China P Rep,Climatological,1,0,27500000,0,0,27500000,0
83 | Asia,CHN,China P Rep,Geophysical,7,737,2431778,3874,0,2435652,6325000
84 | Asia,CHN,China P Rep,Hydrological,12,381,17072700,0,420385,17493085,8237000
85 | Asia,CHN,China P Rep,Meteorological,8,128,10980250,189,36255,11016694,8612973
86 | Asia,GEO,Georgia,Hydrological,1,0,120,0,0,120,0
87 | Asia,IND,India,Hydrological,9,795,4076500,0,650000,4726500,16163000
88 | Asia,IND,India,Meteorological,5,118,929610,26,0,929636,7000000
89 | Asia,IDN,Indonesia,Geophysical,2,39,115088,72,0,115160,186000
90 | Asia,IDN,Indonesia,Hydrological,9,198,433737,0,5250,438987,756000
91 | Asia,IRN,Iran Islam Rep,Geophysical,2,1,85300,90,0,85390,44000
92 | Asia,IRN,Iran Islam Rep,Hydrological,1,37,440000,0,0,440000,49000
93 | Asia,JPN,Japan,Geophysical,2,62,2466,115,99,2680,0
94 | Asia,JPN,Japan,Hydrological,1,82,0,67,0,67,0
95 | Asia,JPN,Japan,Meteorological,7,85,36465,256,0,36721,6300000
96 | Asia,KAZ,Kazakhstan,Hydrological,1,5,2700,9,0,2709,0
97 | Asia,KOR,Korea Rep,Hydrological,1,13,0,0,0,0,0
98 | Asia,KOR,Korea Rep,Meteorological,2,24,0,101,0,101,11000
99 | Asia,KGZ,Kyrgyzstan,Meteorological,1,0,0,0,0,0,0
100 | Asia,LAO,Lao P Dem Rep,Hydrological,1,0,750,0,0,750,0
101 | Asia,MYS,Malaysia,Climatological,1,0,2200000,0,0,2200000,0
102 | Asia,MYS,Malaysia,Hydrological,1,17,230000,0,0,230000,284000
103 | Asia,MMR,Myanmar,Hydrological,2,0,40000,0,0,40000,0
104 | Asia,NPL,Nepal,Hydrological,5,508,187145,149,0,187294,0
105 | Asia,NPL,Nepal,Meteorological,1,43,0,0,0,0,0
106 | Asia,PAK,Pakistan,Climatological,1,248,0,0,0,0,18000
107 | Asia,PAK,Pakistan,Hydrological,1,367,2470000,673,0,2470673,2000000
108 | Asia,PAK,Pakistan,Meteorological,1,16,0,82,0,82,0
109 | Asia,PHL,Philippines,Geophysical,1,0,60545,0,0,60545,0
110 | Asia,PHL,Philippines,Hydrological,2,4,102955,0,0,102955,0
111 | Asia,PHL,Philippines,Meteorological,9,304,9978563,1456,0,9980019,290563
112 | Asia,LKA,Sri Lanka,Climatological,1,0,1800000,0,0,1800000,25000
113 | Asia,LKA,Sri Lanka,Hydrological,4,113,1204400,29,330,1204759,0
114 | Asia,TWN,Taiwan (China),Meteorological,2,0,0,0,0,0,420000
115 | Asia,TJK,Tajikistan,Hydrological,2,20,12760,38,425,13223,0
116 | Asia,THA,Thailand,Climatological,1,0,0,0,0,0,0
117 | Asia,THA,Thailand,Geophysical,1,1,17500,23,0,17523,62000
118 | Asia,THA,Thailand,Hydrological,4,29,131280,8,0,131288,10000
119 | Asia,THA,Thailand,Meteorological,1,63,1000000,0,0,1000000,0
120 | Asia,TLS,Timor-Leste,Biological,1,2,0,197,0,197,0
121 | Asia,TUR,Turkey,Geophysical,1,0,0,324,0,324,0
122 | Asia,VNM,Viet Nam,Meteorological,3,38,48075,0,0,48075,10425
123 | Europe,BLR,Belarus,Meteorological,1,2,30000,1500,0,31500,0
124 | Europe,BEL,Belgium,Meteorological,1,0,0,0,0,0,0
125 | Europe,BIH,Bosnia-Hercegovenia,Hydrological,3,25,1000000,0,0,1000000,436580
126 | Europe,BGR,Bulgaria,Hydrological,4,20,7847,0,0,7847,48000
127 | Europe,HRV,Croatia,Hydrological,2,3,9116,0,0,9116,0
128 | Europe,FRA,France,Hydrological,3,14,4000,0,0,4000,0
129 | Europe,FRA,France,Meteorological,3,2,0,0,0,0,0
130 | Europe,DEU,Germany,Meteorological,1,6,0,0,0,0,0
131 | Europe,GRC,Greece,Geophysical,2,3,77000,25,0,77025,450000
132 | Europe,GRC,Greece,Hydrological,1,0,0,0,0,0,0
133 | Europe,HUN,Hungary,Hydrological,1,0,6500,0,0,6500,0
134 | Europe,IRL,Ireland,Meteorological,1,1,0,0,0,0,0
135 | Europe,ITA,Italy,Hydrological,1,1,600,0,0,600,0
136 | Europe,ITA,Italy,Meteorological,1,5,0,0,0,0,250000
137 | Europe,POL,Poland,Meteorological,1,17,0,0,0,0,0
138 | Europe,PRT,Portugal,Meteorological,2,1,50,4,0,54,0
139 | Europe,ROU,Romania,Hydrological,2,4,525,0,0,525,0
140 | Europe,ROU,Romania,Meteorological,1,13,0,0,0,0,0
141 | Europe,RUS,Russia,Hydrological,1,0,22545,0,0,22545,15000
142 | Europe,SRB,Serbia,Hydrological,3,55,1610000,0,0,1610000,2172355
143 | Europe,SRB,Serbia,Meteorological,1,0,3000,0,0,3000,0
144 | Europe,SVN,Slovenia,Hydrological,1,2,600,0,0,600,0
145 | Europe,SVN,Slovenia,Meteorological,1,1,50000,0,0,50000,0
146 | Europe,ESP,Spain,Meteorological,1,3,0,0,0,0,0
147 | Europe,CHE,Switzerland,Meteorological,1,2,0,0,0,0,0
148 | Europe,GBR,United Kingdom,Meteorological,1,5,18000,0,0,18000,100000
149 | Oceania,AUS,Australia,Climatological,1,2,0,0,168,168,25000
150 | Oceania,AUS,Australia,Meteorological,1,0,0,0,0,0,0
151 | Oceania,KIR,Kiribati,Hydrological,1,0,220,0,0,220,0
152 | Oceania,MHL,Marshall Is,Hydrological,1,0,360,0,0,360,0
153 | Oceania,PNG,Papua New Guinea,Geophysical,1,0,1380,0,0,1380,0
154 | Oceania,PNG,Papua New Guinea,Meteorological,1,0,12346,0,0,12346,0
155 | Oceania,SLB,Solomon Is,Hydrological,1,47,52000,0,0,52000,24000
156 | Oceania,TON,Tonga,Meteorological,1,1,4000,14,0,4014,48000
157 | Oceania,VUT,Vanuatu,Meteorological,1,12,20000,6,0,20006,0
158 |
--------------------------------------------------------------------------------
/code_examples/clj-example.clj/src/clj_example/clj.clj:
--------------------------------------------------------------------------------
1 | (ns clj-example.clj
2 | (:require [clojure.string :as str])
3 | (:gen-class))
4 |
5 |
6 | (def data ;; Get data from the csv
7 | (str/split-lines (slurp "resources/data.csv")))
8 |
9 | (def headers ;; Get column headers
10 | (str/split (first data) #","))
11 |
12 | (defn list-data []
13 | "Builds a list of maps with the data."
14 | (mapv #(zipmap headers
15 | (str/split % #","))
16 | (rest data)))
17 |
18 | (defn transform-keys
19 | "Turns keys into keywords and deals with spaces."
20 | [str-key]
21 | (-> str-key
22 | clojure.string/lower-case
23 | (clojure.string/replace #" " "-")
24 | keyword))
25 |
26 | (defn keywordize-keys-with-space
27 | "Recursively transforms all map keys from strings to keywords and deals
28 | with the space for 2 words keys."
29 | [data-map]
30 | (->> data-map
31 | (mapv #(hash-map (transform-keys (key %))
32 | (val %)))
33 | (reduce merge)))
34 |
35 | (defn -main
36 | "List humanitarian data from 2014."
37 | []
38 | (->> (list-data)
39 | (mapv #(keywordize-keys-with-space %))
40 | (keep #(if (> (read-string (:total-affected %)) 0) %))
41 | (mapv #(select-keys % [:country-name :disaster-subgroup]))
42 | (map #(format "%s was affected by a %s disaster" (:country-name %)
43 | (:disaster-subgroup %)))))
44 |
--------------------------------------------------------------------------------
/code_examples/clj-example.clj/test/clj_example/clj_test.clj:
--------------------------------------------------------------------------------
1 | (ns clj-example.clj-test
2 | (:require [clojure.test :refer :all]
3 | [clj-example.clj :refer :all]))
4 |
5 | (deftest a-test
6 | (testing "FIXME, I fail."
7 | (is (= 0 1))))
8 |
--------------------------------------------------------------------------------
/code_examples/data.csv:
--------------------------------------------------------------------------------
1 | continent,Country iso,Country name,disaster subgroup,occurrence,Total deaths,Affected,Injured,Homeless,Total affected,Total damage
2 | Africa,DZA,Algeria,Geophysical,1,6,0,420,0,420,0
3 | Africa,BFA,Burkina Faso,Climatological,1,0,4000000,0,0,4000000,0
4 | Africa,BDI,Burundi,Hydrological,1,96,0,182,12500,12682,0
5 | Africa,CMR,Cameroon,Biological,1,77,1680,0,0,1680,0
6 | Africa,CMR,Cameroon,Hydrological,1,0,2120,0,1380,3500,0
7 | Africa,CPV,Cape Verde Is,Geophysical,1,0,980,0,0,980,0
8 | Africa,COM,Comoros,Geophysical,1,0,10000,0,0,10000,0
9 | Africa,COM,Comoros,Meteorological,1,0,9511,0,0,9511,0
10 | Africa,CIV,Cote d'Ivoire,Hydrological,1,39,0,0,0,0,0
11 | Africa,GMB,Gambia The,Biological,1,0,0,0,0,0,0
12 | Africa,GHA,Ghana,Biological,1,214,26858,0,0,26858,0
13 | Africa,GIN,Guinea,Biological,1,1871,2868,0,0,2868,0
14 | Africa,KEN,Kenya,Climatological,1,0,1600000,0,0,1600000,0
15 | Africa,LSO,Lesotho,Meteorological,1,0,0,0,2600,2600,0
16 | Africa,LBR,Liberia,Biological,1,3613,8464,0,0,8464,0
17 | Africa,MDG,Madagascar,Meteorological,1,17,0,0,1736,1736,0
18 | Africa,MWI,Malawi,Hydrological,1,0,44850,0,0,44850,0
19 | Africa,MLI,Mali,Biological,1,6,7,0,0,7,0
20 | Africa,MAR,Morocco,Hydrological,1,11,0,0,0,0,0
21 | Africa,MAR,Morocco,Meteorological,2,38,117000,0,0,117000,450000
22 | Africa,MOZ,Mozambique,Hydrological,4,22,143760,76,0,143836,0
23 | Africa,NER,Niger,Biological,2,20,5,183,0,188,0
24 | Africa,NER,Niger,Hydrological,1,36,165578,0,0,165578,0
25 | Africa,NGA,Nigeria,Biological,2,186,12244,0,0,12244,0
26 | Africa,NGA,Nigeria,Hydrological,1,15,10000,0,0,10000,0
27 | Africa,SEN,Senegal,Biological,1,0,1,0,0,1,0
28 | Africa,SYC,Seychelles,Hydrological,1,0,4435,0,0,4435,0
29 | Africa,SLE,Sierra Leone,Biological,1,3108,10273,0,0,10273,0
30 | Africa,SOM,Somalia,Climatological,1,0,350000,0,0,350000,0
31 | Africa,SOM,Somalia,Hydrological,1,0,21000,0,0,21000,0
32 | Africa,ZAF,South Africa,Geophysical,1,1,2000,2,0,2002,0
33 | Africa,ZAF,South Africa,Hydrological,1,32,7185,0,0,7185,85000
34 | Africa,SSD,South Sudan,Biological,2,149,5900,586,0,6486,0
35 | Africa,SDN,Sudan,Hydrological,1,77,260000,227,0,260227,0
36 | Africa,SWZ,Swaziland,Hydrological,1,11,400,0,0,400,0
37 | Africa,TZA,Tanzania Uni Rep,Hydrological,2,31,40000,0,0,40000,0
38 | Africa,COD,Zaire/Congo Dem Rep,Biological,1,49,0,17,0,17,0
39 | Africa,COD,Zaire/Congo Dem Rep,Hydrological,2,41,0,0,3750,3750,0
40 | Africa,ZMB,Zambia,Hydrological,1,0,0,0,20000,20000,0
41 | Africa,ZWE,Zimbabwe,Hydrological,2,14,2500,2,0,2502,20000
42 | Americas,ARG,Argentina,Hydrological,3,27,5553,0,0,5553,62000
43 | Americas,BOL,Bolivia,Climatological,1,0,51180,0,0,51180,0
44 | Americas,BOL,Bolivia,Hydrological,1,64,0,0,150000,150000,100000
45 | Americas,BRA,Brazil,Climatological,1,0,0,0,0,0,5000000
46 | Americas,BRA,Brazil,Hydrological,3,45,550600,52,0,550652,0
47 | Americas,CAN,Canada,Meteorological,1,0,0,0,0,0,0
48 | Americas,CHL,Chile,Climatological,1,12,17500,500,0,18000,34000
49 | Americas,CHL,Chile,Geophysical,2,12,1027224,0,0,1027224,200000
50 | Americas,COL,Colombia,Hydrological,4,77,54214,0,0,54214,0
51 | Americas,COL,Colombia,Meteorological,1,11,0,18,0,18,0
52 | Americas,DOM,Dominican Rep,Hydrological,1,1,300,0,0,300,0
53 | Americas,ECU,Ecuador,Geophysical,1,3,0,18,0,18,0
54 | Americas,SLV,El Salvador,Biological,2,4,12906,0,0,12906,0
55 | Americas,GTM,Guatemala,Climatological,1,0,1180000,0,0,1180000,58000
56 | Americas,GTM,Guatemala,Geophysical,1,1,53611,274,9940,63825,0
57 | Americas,GTM,Guatemala,Hydrological,1,0,0,0,0,0,0
58 | Americas,GTM,Guatemala,Meteorological,1,5,100000,0,0,100000,0
59 | Americas,HTI,Haiti,Biological,1,0,68111,0,0,68111,0
60 | Americas,HTI,Haiti,Hydrological,1,12,30000,0,0,30000,0
61 | Americas,HND,Honduras,Climatological,1,0,931555,0,0,931555,0
62 | Americas,HND,Honduras,Hydrological,2,4,23000,0,0,23000,1400
63 | Americas,JAM,Jamaica,Climatological,1,0,91545,0,0,91545,0
64 | Americas,MEX,Mexico,Geophysical,2,3,27381,0,0,27381,0
65 | Americas,MEX,Mexico,Meteorological,6,15,69000,135,0,69135,2539500
66 | Americas,NIC,Nicaragua,Geophysical,1,2,2375,266,0,2641,0
67 | Americas,NIC,Nicaragua,Hydrological,1,0,60345,0,0,60345,0
68 | Americas,PAN,Panama,Hydrological,1,9,116,0,0,116,0
69 | Americas,PRY,Paraguay,Hydrological,1,0,231360,0,0,231360,0
70 | Americas,PER,Peru,Geophysical,1,8,600,4,0,604,0
71 | Americas,PER,Peru,Hydrological,1,0,6300,0,2700,9000,0
72 | Americas,PRI,Puerto Rico,Hydrological,1,1,0,0,0,0,0
73 | Americas,USA,United States,Climatological,2,2,429,0,0,429,4100000
74 | Americas,USA,United States,Geophysical,1,1,3360,172,0,3532,1000000
75 | Americas,USA,United States,Hydrological,2,41,0,0,150,150,100000
76 | Americas,USA,United States,Meteorological,12,169,834,250,30,1114,10716000
77 | Asia,AFG,Afghanistan,Hydrological,2,512,140000,135,10000,150135,0
78 | Asia,AFG,Afghanistan,Meteorological,1,63,0,0,0,0,0
79 | Asia,BGD,Bangladesh,Hydrological,1,59,2800000,447,0,2800447,150000
80 | Asia,BGD,Bangladesh,Meteorological,2,20,6250,12,0,6262,0
81 | Asia,KHM,Cambodia,Hydrological,1,45,57950,0,0,57950,0
82 | Asia,CHN,China P Rep,Climatological,1,0,27500000,0,0,27500000,0
83 | Asia,CHN,China P Rep,Geophysical,7,737,2431778,3874,0,2435652,6325000
84 | Asia,CHN,China P Rep,Hydrological,12,381,17072700,0,420385,17493085,8237000
85 | Asia,CHN,China P Rep,Meteorological,8,128,10980250,189,36255,11016694,8612973
86 | Asia,GEO,Georgia,Hydrological,1,0,120,0,0,120,0
87 | Asia,IND,India,Hydrological,9,795,4076500,0,650000,4726500,16163000
88 | Asia,IND,India,Meteorological,5,118,929610,26,0,929636,7000000
89 | Asia,IDN,Indonesia,Geophysical,2,39,115088,72,0,115160,186000
90 | Asia,IDN,Indonesia,Hydrological,9,198,433737,0,5250,438987,756000
91 | Asia,IRN,Iran Islam Rep,Geophysical,2,1,85300,90,0,85390,44000
92 | Asia,IRN,Iran Islam Rep,Hydrological,1,37,440000,0,0,440000,49000
93 | Asia,JPN,Japan,Geophysical,2,62,2466,115,99,2680,0
94 | Asia,JPN,Japan,Hydrological,1,82,0,67,0,67,0
95 | Asia,JPN,Japan,Meteorological,7,85,36465,256,0,36721,6300000
96 | Asia,KAZ,Kazakhstan,Hydrological,1,5,2700,9,0,2709,0
97 | Asia,KOR,Korea Rep,Hydrological,1,13,0,0,0,0,0
98 | Asia,KOR,Korea Rep,Meteorological,2,24,0,101,0,101,11000
99 | Asia,KGZ,Kyrgyzstan,Meteorological,1,0,0,0,0,0,0
100 | Asia,LAO,Lao P Dem Rep,Hydrological,1,0,750,0,0,750,0
101 | Asia,MYS,Malaysia,Climatological,1,0,2200000,0,0,2200000,0
102 | Asia,MYS,Malaysia,Hydrological,1,17,230000,0,0,230000,284000
103 | Asia,MMR,Myanmar,Hydrological,2,0,40000,0,0,40000,0
104 | Asia,NPL,Nepal,Hydrological,5,508,187145,149,0,187294,0
105 | Asia,NPL,Nepal,Meteorological,1,43,0,0,0,0,0
106 | Asia,PAK,Pakistan,Climatological,1,248,0,0,0,0,18000
107 | Asia,PAK,Pakistan,Hydrological,1,367,2470000,673,0,2470673,2000000
108 | Asia,PAK,Pakistan,Meteorological,1,16,0,82,0,82,0
109 | Asia,PHL,Philippines,Geophysical,1,0,60545,0,0,60545,0
110 | Asia,PHL,Philippines,Hydrological,2,4,102955,0,0,102955,0
111 | Asia,PHL,Philippines,Meteorological,9,304,9978563,1456,0,9980019,290563
112 | Asia,LKA,Sri Lanka,Climatological,1,0,1800000,0,0,1800000,25000
113 | Asia,LKA,Sri Lanka,Hydrological,4,113,1204400,29,330,1204759,0
114 | Asia,TWN,Taiwan (China),Meteorological,2,0,0,0,0,0,420000
115 | Asia,TJK,Tajikistan,Hydrological,2,20,12760,38,425,13223,0
116 | Asia,THA,Thailand,Climatological,1,0,0,0,0,0,0
117 | Asia,THA,Thailand,Geophysical,1,1,17500,23,0,17523,62000
118 | Asia,THA,Thailand,Hydrological,4,29,131280,8,0,131288,10000
119 | Asia,THA,Thailand,Meteorological,1,63,1000000,0,0,1000000,0
120 | Asia,TLS,Timor-Leste,Biological,1,2,0,197,0,197,0
121 | Asia,TUR,Turkey,Geophysical,1,0,0,324,0,324,0
122 | Asia,VNM,Viet Nam,Meteorological,3,38,48075,0,0,48075,10425
123 | Europe,BLR,Belarus,Meteorological,1,2,30000,1500,0,31500,0
124 | Europe,BEL,Belgium,Meteorological,1,0,0,0,0,0,0
125 | Europe,BIH,Bosnia-Hercegovenia,Hydrological,3,25,1000000,0,0,1000000,436580
126 | Europe,BGR,Bulgaria,Hydrological,4,20,7847,0,0,7847,48000
127 | Europe,HRV,Croatia,Hydrological,2,3,9116,0,0,9116,0
128 | Europe,FRA,France,Hydrological,3,14,4000,0,0,4000,0
129 | Europe,FRA,France,Meteorological,3,2,0,0,0,0,0
130 | Europe,DEU,Germany,Meteorological,1,6,0,0,0,0,0
131 | Europe,GRC,Greece,Geophysical,2,3,77000,25,0,77025,450000
132 | Europe,GRC,Greece,Hydrological,1,0,0,0,0,0,0
133 | Europe,HUN,Hungary,Hydrological,1,0,6500,0,0,6500,0
134 | Europe,IRL,Ireland,Meteorological,1,1,0,0,0,0,0
135 | Europe,ITA,Italy,Hydrological,1,1,600,0,0,600,0
136 | Europe,ITA,Italy,Meteorological,1,5,0,0,0,0,250000
137 | Europe,POL,Poland,Meteorological,1,17,0,0,0,0,0
138 | Europe,PRT,Portugal,Meteorological,2,1,50,4,0,54,0
139 | Europe,ROU,Romania,Hydrological,2,4,525,0,0,525,0
140 | Europe,ROU,Romania,Meteorological,1,13,0,0,0,0,0
141 | Europe,RUS,Russia,Hydrological,1,0,22545,0,0,22545,15000
142 | Europe,SRB,Serbia,Hydrological,3,55,1610000,0,0,1610000,2172355
143 | Europe,SRB,Serbia,Meteorological,1,0,3000,0,0,3000,0
144 | Europe,SVN,Slovenia,Hydrological,1,2,600,0,0,600,0
145 | Europe,SVN,Slovenia,Meteorological,1,1,50000,0,0,50000,0
146 | Europe,ESP,Spain,Meteorological,1,3,0,0,0,0,0
147 | Europe,CHE,Switzerland,Meteorological,1,2,0,0,0,0,0
148 | Europe,GBR,United Kingdom,Meteorological,1,5,18000,0,0,18000,100000
149 | Oceania,AUS,Australia,Climatological,1,2,0,0,168,168,25000
150 | Oceania,AUS,Australia,Meteorological,1,0,0,0,0,0,0
151 | Oceania,KIR,Kiribati,Hydrological,1,0,220,0,0,220,0
152 | Oceania,MHL,Marshall Is,Hydrological,1,0,360,0,0,360,0
153 | Oceania,PNG,Papua New Guinea,Geophysical,1,0,1380,0,0,1380,0
154 | Oceania,PNG,Papua New Guinea,Meteorological,1,0,12346,0,0,12346,0
155 | Oceania,SLB,Solomon Is,Hydrological,1,47,52000,0,0,52000,24000
156 | Oceania,TON,Tonga,Meteorological,1,1,4000,14,0,4014,48000
157 | Oceania,VUT,Vanuatu,Meteorological,1,12,20000,6,0,20006,0
158 |
--------------------------------------------------------------------------------
/code_examples/example.py:
--------------------------------------------------------------------------------
1 | import csv
2 |
3 | ## Looking at humanitarian data for 2014
4 | ## from the Emergency Events Database EM-DAT
5 | ## source: http://www.emdat.be/
6 |
7 | def process_csv(filename):
8 | '''Open the file and build a list
9 | containing dictionnaries of data.'''
10 | list_data = []
11 |
12 | with open(filename, 'rb') as csvfile:
13 | content = csv.reader(csvfile)
14 | headers = content.next()
15 | data = content
16 |
17 | for row in data:
18 | dict_data = {}
19 | for i in range(len(headers)):
20 | dict_data[headers[i]] = row[i]
21 | list_data.append(dict_data)
22 | return list_data
23 |
24 |
25 | def countries_affected(data):
26 | '''Search for countries with people
27 | affected and return them along with
28 | the cause.'''
29 | list_affected = []
30 |
31 | for element in data:
32 | if float(element['Total affected']) > 0:
33 | list_affected.append({
34 | 'affected country': element['Country name'],
35 | 'type disaster': element['disaster subgroup']
36 | })
37 | return list_affected
38 |
39 |
40 |
41 | if __name__ == "__main__":
42 | disaster_data_2014 = process_csv('data.csv')
43 | total_affected = countries_affected(disaster_data_2014)
44 | for r in total_affected:
45 | print '%s was affected by a %s disaster' %(r.get('affected country'), r.get('type disaster'))
46 |
47 |
--------------------------------------------------------------------------------
/code_examples/example_functional.py:
--------------------------------------------------------------------------------
1 | import csv
2 |
3 | ## Looking at humanitarian data for 2014
4 | ## from the Emergency Events Database EM-DAT
5 | ## source: http://www.emdat.be/
6 |
7 | def process_csv(filename):
8 | '''Open the file and build a list
9 | containing dictionnaries of data.'''
10 | with open(filename, 'rb') as csvfile:
11 | content = csv.reader(csvfile)
12 | headers = content.next()
13 | data = [row for row in content]
14 | list_data = [dict(zip(headers, row)) for row in data]
15 | return list_data
16 |
17 | def countries_affected(data):
18 | '''Search for countries with people
19 | affected and return them along with
20 | the cause.'''
21 | list_affected = [{
22 | 'affected country': element['Country name'],
23 | 'type disaster': element['disaster subgroup']
24 | } for element in data if float(element['Total affected']) > 0]
25 |
26 | return list_affected
27 |
28 | if __name__ == "__main__":
29 | disaster_data_2014 = process_csv('data.csv')
30 | total_affected = countries_affected(disaster_data_2014)
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/img/(.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/(.png
--------------------------------------------------------------------------------
/img/clj-def-fn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/clj-def-fn.png
--------------------------------------------------------------------------------
/img/clj-defn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/clj-defn.png
--------------------------------------------------------------------------------
/img/clj-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/clj-example.png
--------------------------------------------------------------------------------
/img/clj-map.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/clj-map.png
--------------------------------------------------------------------------------
/img/clj_conj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/clj_conj.png
--------------------------------------------------------------------------------
/img/clj_def.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/clj_def.png
--------------------------------------------------------------------------------
/img/clj_list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/clj_list.png
--------------------------------------------------------------------------------
/img/clj_map.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/clj_map.png
--------------------------------------------------------------------------------
/img/clj_set.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/clj_set.png
--------------------------------------------------------------------------------
/img/clj_vector.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/clj_vector.png
--------------------------------------------------------------------------------
/img/lein_new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/lein_new.png
--------------------------------------------------------------------------------
/img/lein_repl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/lein_repl.png
--------------------------------------------------------------------------------
/img/lein_run.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/lein_run.png
--------------------------------------------------------------------------------
/img/lein_test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/lein_test.png
--------------------------------------------------------------------------------
/img/lein_uberjar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/lein_uberjar.png
--------------------------------------------------------------------------------
/img/lisp_cycles.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/lisp_cycles.png
--------------------------------------------------------------------------------
/img/python-fun-lambda.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/python-fun-lambda.png
--------------------------------------------------------------------------------
/img/python-iter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/python-iter.png
--------------------------------------------------------------------------------
/img/python-lambda.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/python-lambda.png
--------------------------------------------------------------------------------
/img/python_example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/python_example.png
--------------------------------------------------------------------------------
/img/python_fun_ex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/python_fun_ex.png
--------------------------------------------------------------------------------
/img/python_lc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/python_lc.png
--------------------------------------------------------------------------------
/img/python_tuple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/img/python_tuple.png
--------------------------------------------------------------------------------
/python_to_clojure.odp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/python_to_clojure.odp
--------------------------------------------------------------------------------
/python_to_clojure.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Eleonore9/from-python-to-clojure/464e8e957d3e4d134785f7004154987f556e1906/python_to_clojure.pdf
--------------------------------------------------------------------------------