├── .gitignore ├── LICENSE ├── README.md ├── one ├── README.md ├── dev │ └── user.clj ├── project.clj ├── resources │ ├── coba.edn │ └── coba.txt └── src │ └── one │ ├── a.clj │ ├── b.clj │ ├── c.clj │ └── d.clj ├── pratwo ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── doc │ └── intro.md ├── project.clj ├── resources │ └── data1.json ├── src │ └── pratwo │ │ ├── core.clj │ │ ├── dbase │ │ └── one.clj │ │ ├── intermediate │ │ ├── recprot.clj │ │ ├── stm.clj │ │ └── trans.clj │ │ ├── json │ │ └── one.clj │ │ ├── one.clj │ │ ├── prime │ │ └── one.clj │ │ ├── stat.clj │ │ └── two.clj └── test │ └── pratwo │ └── stat.clj ├── proone ├── .gitignore ├── LICENSE ├── README.md ├── dev │ └── user.clj ├── doc │ └── intro.md ├── project.clj ├── resources │ ├── gogom.edn │ └── one.html ├── src │ └── proone │ │ ├── alfa.clj │ │ ├── core.clj │ │ └── tfor.clj └── test │ └── proone │ └── core_test.clj ├── sscom ├── .gitignore ├── LICENSE ├── README.md ├── doc │ └── intro.md ├── project.clj ├── resources │ └── config.edn ├── src │ └── sscom │ │ ├── core.clj │ │ ├── dbase.clj │ │ ├── routes.clj │ │ ├── server.clj │ │ └── system.clj └── test │ └── sscom │ └── core_test.clj └── tutone ├── project.clj └── src └── tutone └── a.clj /.gitignore: -------------------------------------------------------------------------------- 1 | pom.xml 2 | pom.xml.asc 3 | *jar 4 | /lib/ 5 | /classes/ 6 | /target/ 7 | /checkouts/ 8 | .lein-deps-sum 9 | .lein-repl-history 10 | .lein-plugins/ 11 | .lein-failures 12 | .nrepl-port 13 | *.iml 14 | *idea* -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Eclipse Public License - v 1.0 2 | 3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 4 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 5 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 6 | 7 | 1. DEFINITIONS 8 | 9 | "Contribution" means: 10 | 11 | a) in the case of the initial Contributor, the initial code and documentation 12 | distributed under this Agreement, and 13 | b) in the case of each subsequent Contributor: 14 | i) changes to the Program, and 15 | ii) additions to the Program; 16 | 17 | where such changes and/or additions to the Program originate from and are 18 | distributed by that particular Contributor. A Contribution 'originates' 19 | from a Contributor if it was added to the Program by such Contributor 20 | itself or anyone acting on such Contributor's behalf. Contributions do not 21 | include additions to the Program which: (i) are separate modules of 22 | software distributed in conjunction with the Program under their own 23 | license agreement, and (ii) are not derivative works of the Program. 24 | 25 | "Contributor" means any person or entity that distributes the Program. 26 | 27 | "Licensed Patents" mean patent claims licensable by a Contributor which are 28 | necessarily infringed by the use or sale of its Contribution alone or when 29 | combined with the Program. 30 | 31 | "Program" means the Contributions distributed in accordance with this 32 | Agreement. 33 | 34 | "Recipient" means anyone who receives the Program under this Agreement, 35 | including all Contributors. 36 | 37 | 2. GRANT OF RIGHTS 38 | a) Subject to the terms of this Agreement, each Contributor hereby grants 39 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 40 | reproduce, prepare derivative works of, publicly display, publicly 41 | perform, distribute and sublicense the Contribution of such Contributor, 42 | if any, and such derivative works, in source code and object code form. 43 | b) Subject to the terms of this Agreement, each Contributor hereby grants 44 | Recipient a non-exclusive, worldwide, royalty-free patent license under 45 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 46 | transfer the Contribution of such Contributor, if any, in source code and 47 | object code form. This patent license shall apply to the combination of 48 | the Contribution and the Program if, at the time the Contribution is 49 | added by the Contributor, such addition of the Contribution causes such 50 | combination to be covered by the Licensed Patents. The patent license 51 | shall not apply to any other combinations which include the Contribution. 52 | No hardware per se is licensed hereunder. 53 | c) Recipient understands that although each Contributor grants the licenses 54 | to its Contributions set forth herein, no assurances are provided by any 55 | Contributor that the Program does not infringe the patent or other 56 | intellectual property rights of any other entity. Each Contributor 57 | disclaims any liability to Recipient for claims brought by any other 58 | entity based on infringement of intellectual property rights or 59 | otherwise. As a condition to exercising the rights and licenses granted 60 | hereunder, each Recipient hereby assumes sole responsibility to secure 61 | any other intellectual property rights needed, if any. For example, if a 62 | third party patent license is required to allow Recipient to distribute 63 | the Program, it is Recipient's responsibility to acquire that license 64 | before distributing the Program. 65 | d) Each Contributor represents that to its knowledge it has sufficient 66 | copyright rights in its Contribution, if any, to grant the copyright 67 | license set forth in this Agreement. 68 | 69 | 3. REQUIREMENTS 70 | 71 | A Contributor may choose to distribute the Program in object code form under 72 | its own license agreement, provided that: 73 | 74 | a) it complies with the terms and conditions of this Agreement; and 75 | b) its license agreement: 76 | i) effectively disclaims on behalf of all Contributors all warranties 77 | and conditions, express and implied, including warranties or 78 | conditions of title and non-infringement, and implied warranties or 79 | conditions of merchantability and fitness for a particular purpose; 80 | ii) effectively excludes on behalf of all Contributors all liability for 81 | damages, including direct, indirect, special, incidental and 82 | consequential damages, such as lost profits; 83 | iii) states that any provisions which differ from this Agreement are 84 | offered by that Contributor alone and not by any other party; and 85 | iv) states that source code for the Program is available from such 86 | Contributor, and informs licensees how to obtain it in a reasonable 87 | manner on or through a medium customarily used for software exchange. 88 | 89 | When the Program is made available in source code form: 90 | 91 | a) it must be made available under this Agreement; and 92 | b) a copy of this Agreement must be included with each copy of the Program. 93 | Contributors may not remove or alter any copyright notices contained 94 | within the Program. 95 | 96 | Each Contributor must identify itself as the originator of its Contribution, 97 | if 98 | any, in a manner that reasonably allows subsequent Recipients to identify the 99 | originator of the Contribution. 100 | 101 | 4. COMMERCIAL DISTRIBUTION 102 | 103 | Commercial distributors of software may accept certain responsibilities with 104 | respect to end users, business partners and the like. While this license is 105 | intended to facilitate the commercial use of the Program, the Contributor who 106 | includes the Program in a commercial product offering should do so in a manner 107 | which does not create potential liability for other Contributors. Therefore, 108 | if a Contributor includes the Program in a commercial product offering, such 109 | Contributor ("Commercial Contributor") hereby agrees to defend and indemnify 110 | every other Contributor ("Indemnified Contributor") against any losses, 111 | damages and costs (collectively "Losses") arising from claims, lawsuits and 112 | other legal actions brought by a third party against the Indemnified 113 | Contributor to the extent caused by the acts or omissions of such Commercial 114 | Contributor in connection with its distribution of the Program in a commercial 115 | product offering. The obligations in this section do not apply to any claims 116 | or Losses relating to any actual or alleged intellectual property 117 | infringement. In order to qualify, an Indemnified Contributor must: 118 | a) promptly notify the Commercial Contributor in writing of such claim, and 119 | b) allow the Commercial Contributor to control, and cooperate with the 120 | Commercial Contributor in, the defense and any related settlement 121 | negotiations. The Indemnified Contributor may participate in any such claim at 122 | its own expense. 123 | 124 | For example, a Contributor might include the Program in a commercial product 125 | offering, Product X. That Contributor is then a Commercial Contributor. If 126 | that Commercial Contributor then makes performance claims, or offers 127 | warranties related to Product X, those performance claims and warranties are 128 | such Commercial Contributor's responsibility alone. Under this section, the 129 | Commercial Contributor would have to defend claims against the other 130 | Contributors related to those performance claims and warranties, and if a 131 | court requires any other Contributor to pay any damages as a result, the 132 | Commercial Contributor must pay those damages. 133 | 134 | 5. NO WARRANTY 135 | 136 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN 137 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR 138 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, 139 | NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each 140 | Recipient is solely responsible for determining the appropriateness of using 141 | and distributing the Program and assumes all risks associated with its 142 | exercise of rights under this Agreement , including but not limited to the 143 | risks and costs of program errors, compliance with applicable laws, damage to 144 | or loss of data, programs or equipment, and unavailability or interruption of 145 | operations. 146 | 147 | 6. DISCLAIMER OF LIABILITY 148 | 149 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 150 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 151 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 152 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 153 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 154 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 155 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 156 | OF SUCH DAMAGES. 157 | 158 | 7. GENERAL 159 | 160 | If any provision of this Agreement is invalid or unenforceable under 161 | applicable law, it shall not affect the validity or enforceability of the 162 | remainder of the terms of this Agreement, and without further action by the 163 | parties hereto, such provision shall be reformed to the minimum extent 164 | necessary to make such provision valid and enforceable. 165 | 166 | If Recipient institutes patent litigation against any entity (including a 167 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 168 | (excluding combinations of the Program with other software or hardware) 169 | infringes such Recipient's patent(s), then such Recipient's rights granted 170 | under Section 2(b) shall terminate as of the date such litigation is filed. 171 | 172 | All Recipient's rights under this Agreement shall terminate if it fails to 173 | comply with any of the material terms or conditions of this Agreement and does 174 | not cure such failure in a reasonable period of time after becoming aware of 175 | such noncompliance. If all Recipient's rights under this Agreement terminate, 176 | Recipient agrees to cease use and distribution of the Program as soon as 177 | reasonably practicable. However, Recipient's obligations under this Agreement 178 | and any licenses granted by Recipient relating to the Program shall continue 179 | and survive. 180 | 181 | Everyone is permitted to copy and distribute copies of this Agreement, but in 182 | order to avoid inconsistency the Agreement is copyrighted and may only be 183 | modified in the following manner. The Agreement Steward reserves the right to 184 | publish new versions (including revisions) of this Agreement from time to 185 | time. No one other than the Agreement Steward has the right to modify this 186 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 187 | Eclipse Foundation may assign the responsibility to serve as the Agreement 188 | Steward to a suitable separate entity. Each new version of the Agreement will 189 | be given a distinguishing version number. The Program (including 190 | Contributions) may always be distributed subject to the version of the 191 | Agreement under which it was received. In addition, after a new version of the 192 | Agreement is published, Contributor may elect to distribute the Program 193 | (including its Contributions) under the new version. Except as expressly 194 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 195 | licenses to the intellectual property of any Contributor under this Agreement, 196 | whether expressly, by implication, estoppel or otherwise. All rights in the 197 | Program not expressly granted under this Agreement are reserved. 198 | 199 | This Agreement is governed by the laws of the State of New York and the 200 | intellectual property laws of the United States of America. No party to this 201 | Agreement will bring a legal action under this Agreement more than one year 202 | after the cause of action arose. Each party waives its rights to a jury trial in 203 | any resulting litigation. 204 | 205 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Clojure Tutorial 2 | 3 | Clojure tutorial in Bahasa Indonesia (video version) 4 | 5 | This tutorial assumes you have an introductory programming background (preferrably using Haskell). 6 | If you don't then try [this one](https://github.com/Zenius2016/BoardAlfa). Why Clojure? [here](http://www.infoq.com/presentations/Simple-Made-Easy). 7 | 8 | ## Easy/Quick installation 9 | 10 | 1. [JDK 1.8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) 11 | 2. [Download nightcode] (https://sekao.net/nightcode/) 12 | 13 | ## Youtube Playlists (Table of content) 14 | 15 | 1. [Language Basic & REPL](https://youtu.be/NXxJavT7ILY?list=PLlTjr2CPUG1-tA4FMIGCCyJFGuZbB-gpq) 16 | 1.1 [Installation & Clojure Introduction](https://www.youtube.com/watch?v=NXxJavT7ILY&feature=youtu.be&list=PLlTjr2CPUG1-tA4FMIGCCyJFGuZbB-gpq) 17 | 1.2 [Basic Data Types & Operations](https://www.youtube.com/watch?v=h-e5epfgGp0&list=PLlTjr2CPUG1-tA4FMIGCCyJFGuZbB-gpq&index=2) 18 | 1.3 [Collections (List, Vector, Maps, Set)](https://www.youtube.com/watch?v=7uRzGD8h8b8&index=3&list=PLlTjr2CPUG1-tA4FMIGCCyJFGuZbB-gpq) 19 | 1.4 [Symbols & Identifier](https://www.youtube.com/watch?v=PRfFqxHJqYY&list=PLlTjr2CPUG1-tA4FMIGCCyJFGuZbB-gpq&index=4) 20 | 1.5 [Exercise 1: Expression](https://www.youtube.com/watch?v=Q-Q5ViMOkeE&index=5&list=PLlTjr2CPUG1-tA4FMIGCCyJFGuZbB-gpq) 21 | 1.6 [Exercise 2: List Manipulation ](https://www.youtube.com/watch?v=8F6lRTbePGA&list=PLlTjr2CPUG1-tA4FMIGCCyJFGuZbB-gpq&index=6) 22 | 1.7 [Exercise 3: Vector Manipulation](https://www.youtube.com/watch?v=3tM3P4_hz-c&index=7&list=PLlTjr2CPUG1-tA4FMIGCCyJFGuZbB-gpq) 23 | 1.8 [Exercise 4: Set and Maps ](https://www.youtube.com/watch?v=jHBexy6tVXU&list=PLlTjr2CPUG1-tA4FMIGCCyJFGuZbB-gpq&index=8) 24 | 1.9 [Exercise 5: Defining a Function](https://www.youtube.com/watch?v=g5EqfyzuYl8&index=9&list=PLlTjr2CPUG1-tA4FMIGCCyJFGuZbB-gpq) 25 |     1.9.1 [Function can beget another](https://youtu.be/g5EqfyzuYl8?list=PLlTjr2CPUG1-tA4FMIGCCyJFGuZbB-gpq&t=8m49s) 26 |     1.9.2 [Higher-order function take function arguments](https://youtu.be/g5EqfyzuYl8?t=16m16s) 27 | 2. [Source Code](https://www.youtube.com/watch?v=KLgrUWyqGgw&feature=youtu.be&list=PLlTjr2CPUG187bvI0lY00K6n1GVbyFLdU) 28 | 2.1 [How to Make Clojure File](https://www.youtube.com/watch?v=KLgrUWyqGgw&feature=youtu.be&list=PLlTjr2CPUG187bvI0lY00K6n1GVbyFLdU) 29 | 2.2 [4Clojure Introduction](https://www.youtube.com/watch?v=ihX2k1Ig2q0&index=2&list=PLlTjr2CPUG187bvI0lY00K6n1GVbyFLdU) 30 | 2.3 [Conditional (`if` and `cond`) ](https://www.youtube.com/watch?v=o8wqw7A1xj8&list=PLlTjr2CPUG187bvI0lY00K6n1GVbyFLdU&index=3) 31 | 2.4 [Conditional Continue & Collections](https://www.youtube.com/watch?v=MhoS_U8eg10&index=4&list=PLlTjr2CPUG187bvI0lY00K6n1GVbyFLdU) 32 | 2.5 [Clojure Docs & Clojure Evaluation](https://www.youtube.com/watch?v=EyCbsZ-mVmI&index=5&list=PLlTjr2CPUG187bvI0lY00K6n1GVbyFLdU) 33 | 2.6 [Clojure Evaluation Continue](https://www.youtube.com/watch?v=v8edssoaXuo&index=6&list=PLlTjr2CPUG187bvI0lY00K6n1GVbyFLdU) 34 | 2.7 [Recursion ex. Factorial](https://www.youtube.com/watch?v=VBqGy5E0LwY&list=PLlTjr2CPUG187bvI0lY00K6n1GVbyFLdU&index=7) 35 | 2.8 [Recursion Continue](https://www.youtube.com/watch?v=D4gft10cC_E&index=8&list=PLlTjr2CPUG187bvI0lY00K6n1GVbyFLdU) 36 | 3. [Clojure Expression](https://www.youtube.com/watch?v=74lhwCaL5_g&list=PLlTjr2CPUG18iBKGdoSQQsoJJeErVrqyY) 37 | 3.1 [Function](https://www.youtube.com/watch?v=74lhwCaL5_g&list=PLlTjr2CPUG18iBKGdoSQQsoJJeErVrqyY) 38 | 3.2 [Data Structure](https://www.youtube.com/watch?v=IoJ22_Ro4M4&index=2&list=PLlTjr2CPUG18iBKGdoSQQsoJJeErVrqyY) 39 | 3.3 [`if` Conditional](https://www.youtube.com/watch?v=w7CR_rDC7tQ&list=PLlTjr2CPUG18iBKGdoSQQsoJJeErVrqyY&index=3) 40 | 3.4 [Recursion](https://www.youtube.com/watch?v=u6IDIX1rJV4&list=PLlTjr2CPUG18iBKGdoSQQsoJJeErVrqyY&index=4) 41 | 3.5 [True and False Conditional](https://www.youtube.com/watch?v=yE3mU5b8rBs&list=PLlTjr2CPUG18iBKGdoSQQsoJJeErVrqyY&index=5) 42 | 3.6 [Brute-force Prime](https://www.youtube.com/watch?v=GaeIDpdfpc0&index=6&list=PLlTjr2CPUG18iBKGdoSQQsoJJeErVrqyY) 43 | 3.7 [Efficient Prime Algorithm ](https://www.youtube.com/watch?v=oiXewIUjGVg&index=7&list=PLlTjr2CPUG18iBKGdoSQQsoJJeErVrqyY) 44 | 3.8 [Pure Recursion & Looping](https://www.youtube.com/watch?v=oLmamghbW_g&list=PLlTjr2CPUG18iBKGdoSQQsoJJeErVrqyY&index=8) 45 | 4. [Higher Order Functions](https://www.youtube.com/playlist?list=PLlTjr2CPUG185iOkewp5i-uVoflhSrw_z) 46 | 4.1 [Idiomatic clojure: destructuring with `[[x & xs]]` style. Start at 9.05: `map`, `reduce`](https://www.youtube.com/watch?v=9rHL8yTWZQo&list=PLlTjr2CPUG185iOkewp5i-uVoflhSrw_z&index=1) 47 | 4.2 [Pattern: `->`, `->>`](https://www.youtube.com/watch?v=25Xs7OdkQqk&list=PLlTjr2CPUG185iOkewp5i-uVoflhSrw_z&index=2) 48 | 4.3 [High order fn, input fn: `map-indexed`, `keep`, `when`, `mapv`, `filter`, `filterv`](https://www.youtube.com/watch?v=kH9m9h08090&list=PLlTjr2CPUG185iOkewp5i-uVoflhSrw_z&index=3) 49 | 4.4 [Global and local scope: `let`](https://www.youtube.com/watch?v=h5rSmJmn_U4&list=PLlTjr2CPUG185iOkewp5i-uVoflhSrw_z&index=4) 50 | 4.5 [High order fn, input fn: `remove`, `shuffle`, `sort`, `sort-by`, `apply`, `max`, `min`, `partition`, `partition-by`, `take-while`, `drop-while`, `group-by`](https://www.youtube.com/watch?v=YMbIaJ7c_fw&list=PLlTjr2CPUG185iOkewp5i-uVoflhSrw_z&index=5) 51 | 4.6 [Map manipulation: `zipmap`, `keys`, `vals`, `into`, `identity`](https://www.youtube.com/watch?v=MMXKQAb3ofw&list=PLlTjr2CPUG185iOkewp5i-uVoflhSrw_z&index=6) 52 | 4.7 [Map manipulation: `assoc`, `dissoc`, `merge`, `merge-with`, `get-in`, `update-in`, `assoc-in`](https://www.youtube.com/watch?v=wdlZXeMafr4&list=PLlTjr2CPUG185iOkewp5i-uVoflhSrw_z&index=7) 53 | 4.8 [High order fn, input fn: `every?`, `some`, `mapcat`, `iterate`](https://www.youtube.com/watch?v=nSJpRzVvUdE&list=PLlTjr2CPUG185iOkewp5i-uVoflhSrw_z&index=8) 54 | 4.9 [High order fn, output fn: soal generator. `comp`, `juxt`, `partial`](https://www.youtube.com/watch?v=tbMZnX5Nzd0&list=PLlTjr2CPUG185iOkewp5i-uVoflhSrw_z&index=9) 55 | 5. [For, side-effects, and many others](https://www.youtube.com/watch?v=CMicaVzbds4&list=PLlTjr2CPUG195scQQ6m0YMWIoXQy3e6rH) 56 | 5.1 [`for`](https://www.youtube.com/watch?v=6Z2mO0gX6cg&index=1&list=PLlTjr2CPUG195scQQ6m0YMWIoXQy3e6rH) 57 | 5.2 [`for` continue](https://www.youtube.com/watch?v=reejSd_eGqM&index=2&list=PLlTjr2CPUG195scQQ6m0YMWIoXQy3e6rH) 58 | 5.3 [`apply`, `reduce`, `eval`](https://www.youtube.com/watch?v=CMicaVzbds4&index=3&list=PLlTjr2CPUG195scQQ6m0YMWIoXQy3e6rH) 59 | 5.4 [Impure function, side effect!. Finally `atom`, `reset!`, `@`, `dotimes`, `println`, `do`, `doseq`](https://www.youtube.com/watch?v=sPCbG_gJIpY&index=4&list=PLlTjr2CPUG195scQQ6m0YMWIoXQy3e6rH) 60 | 5.5 [ProjectEuler No. 1](https://www.youtube.com/watch?v=hedoC801Hos&index=5&list=PLlTjr2CPUG195scQQ6m0YMWIoXQy3e6rH) 61 | 5.6 [ProjectEuler No. 2, `memoize`](https://www.youtube.com/watch?v=xuZUISmaiiI&index=6&list=PLlTjr2CPUG195scQQ6m0YMWIoXQy3e6rH) 62 | 5.7 [IO Side effect!, `slurp`, `read-string`, edn???](https://www.youtube.com/watch?v=IqD3kl86JkA&index=7&list=PLlTjr2CPUG195scQQ6m0YMWIoXQy3e6rH) 63 | 5.8 [ProjectEuler No. 14, `max-key`, `juxt`](https://www.youtube.com/watch?v=A73GHXAVf2g&index=8&list=PLlTjr2CPUG195scQQ6m0YMWIoXQy3e6rH) 64 | 65 | ## Special playlist(s) 66 | 67 | 1. [Using Paredit to boost productivity](https://www.youtube.com/playlist?list=PLlTjr2CPUG19Yq3XMnjfquTQdltu2QOOM) (VERY IMPORTANT!). 68 | 69 | ## Practical Clojure & Apps development 70 | 71 | The examples for this part is on a [different repo somehow](https://github.com/squest/Clojure-practical-examples) 72 | 73 | 1. [Basic practical Clojure](https://www.youtube.com/watch?v=BaRhEEWvoGk&index=1&list=PLlTjr2CPUG18jcaWKAiNlj6T4uZSgWUeg) 74 | 75 | ### Important exercises 76 | 77 | 1. [4Clojure](http://www.4clojure.com) 78 | 2. [Euler](http://www.projecteuler.ne) 79 | 80 | ### Other learning resources 81 | 82 | 1. [Clojure cheat-sheet](https://clojuredocs.org/quickref) 83 | 2. [Clojure community tutorial](http://clojure-doc.org/articles/content.html) 84 | 3. [Clojure for the brave and true](http://www.braveclojure.com) 85 | 86 | 87 | ### Tools 88 | 89 | 1. [JVM](http://www.java.com/en/download/manual.jsp) 90 | 2. [Leiningen](http://leiningen.org/) 91 | 3. [Nightcode](https://sekao.net/nightcode/) 92 | 4. If you need an advanced Clojure IDE, try Emacs+cider+paredit or IntelliJ with Cursive for a much more productive workflow and better integration with Paredit + Java environment (IntelliJ) 93 | -------------------------------------------------------------------------------- /one/README.md: -------------------------------------------------------------------------------- 1 | # one 2 | 3 | A Clojure app to ... well, that part is up to you. 4 | 5 | ## Usage 6 | 7 | FIXME 8 | -------------------------------------------------------------------------------- /one/dev/user.clj: -------------------------------------------------------------------------------- 1 | (ns user) 2 | 3 | (defn foo [a-list] 4 | (reduce #(+ % %2) a-list)) 5 | 6 | ;; [1 2 3 4 5] 7 | ;; (+ 1 2) => 3 8 | ;; (+ 3 3) => 6 9 | ;; (+ 6 4) => 10 10 | ;; (+ 10 5) => 15 11 | 12 | 13 | (defn foo-too [l] 14 | (reduce (fn [a b] (cons b (reverse a))) [] l)) 15 | 16 | ;; [] 0 => [0] 17 | ;; [0] 1 => (1 0) 18 | ;; (1 0) 2 => (2 0 1) 19 | 20 | (defn prime? [n] 21 | (->> (range 2 (inc (int (Math/sqrt n)))) 22 | (every? #(pos? (rem n %))))) 23 | -------------------------------------------------------------------------------- /one/project.clj: -------------------------------------------------------------------------------- 1 | (defproject one "0.0.1-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :dependencies [[org.clojure/clojure "1.7.0"]] 4 | :javac-options ["-target" "1.8" "-source" "1.8" "-Xlint:-options"] 5 | :profiles {:dev {:source-paths ["dev"]}} 6 | :aot [one.a] 7 | :main one.a) 8 | -------------------------------------------------------------------------------- /one/resources/coba.edn: -------------------------------------------------------------------------------- 1 | 1 2 3 4 5 6 7 8 -------------------------------------------------------------------------------- /one/resources/coba.txt: -------------------------------------------------------------------------------- 1 | sore mbak! -------------------------------------------------------------------------------- /one/src/one/a.clj: -------------------------------------------------------------------------------- 1 | (ns one.a) 2 | 3 | (defn square 4 | [x] 5 | (* x x)) 6 | 7 | (defn cube 8 | [x] 9 | (* x x x)) 10 | 11 | (defn mutlak 12 | [x] 13 | (if (pos? x) x (- x))) 14 | 15 | (defn what-this? 16 | [x] 17 | (cond 18 | (pos? x) "positif" 19 | (neg? x) "negatip" 20 | :else "enol")) 21 | 22 | (def x 123) 23 | 24 | (comment 25 | nyari => kecap?) 26 | 27 | (defn kecap 28 | [a b c] 29 | (let [det (Math/sqrt (- (square b) (* 4 a c)))] 30 | [(/ (+ (- b) det) (* 2 a)) 31 | (/ (- (- b) det) (* 2 a))])) 32 | 33 | (defn ngasal1 34 | [x] 35 | (let [a (+ x x)] 36 | (let [b (* a x)] 37 | (+ a b x)))) 38 | 39 | (comment 40 | (let [a 1] 41 | (let [b (+ a 10)] 42 | (* a b (+ a b)))) 43 | 44 | (let [b (+ 1 10)] 45 | (* 1 b (+ 1 b))) 46 | 47 | (* 1 11 (+ 1 11)) 48 | 49 | (* 1 11 12)) 50 | 51 | (comment 52 | (* (- 9 3) (+ (* 3 2) 43)) 53 | (* 6 (+ 6 43)) 54 | (* 6 49)) 55 | 56 | (defn kecap 57 | [a b c x?] 58 | (let [adisk (Math/sqrt (- (square b) (* 4 a c)))] 59 | (/ (+ (- b) 60 | (if (= x? 1) 61 | adisk 62 | (- adisk))) 63 | (* 2 a)))) 64 | 65 | (defn sayhello 66 | [nama] 67 | (str "Hello, " nama "!")) 68 | 69 | ;; n! = n * (n-1)! 70 | ;; n! => n == 1 => n! = 1 71 | 72 | (defn faktorial 73 | [n] 74 | (if (<= n 1) 75 | 1 76 | (* n (faktorial (dec n))))) 77 | 78 | (comment 79 | (faktorial 4) => (* 4 (faktorial 3)) => (* 4 6) => 24 80 | (faktorial 3) => (* 3 (faktorial 2)) => (* 3 2) 81 | (faktorial 2) => (* 2 (faktorial 1)) => (* 2 1) 82 | (faktorial 1) => 1) 83 | 84 | ;; sum, product, take, drop, fibo 85 | 86 | (defn sum 87 | [xs] 88 | (if (empty? xs) 89 | 0 90 | (+ (first xs) (sum (rest xs))))) 91 | 92 | (defn sum' 93 | [[x & xs]] 94 | (if x (+ x (sum' xs)) 0)) 95 | 96 | 97 | (defn drop' 98 | [n xs] 99 | (cond 100 | (zero? n) xs 101 | (empty? xs) '() 102 | :else (drop' (- n 1) (rest xs)))) 103 | 104 | ;; product, take, fibo 105 | ;; map, reduce, filter, keep, 106 | ;; zipmap, merge, assoc, dissoc, dll 107 | 108 | (comment 109 | (drop 3 [1 2 3 4 5 6 7]) 110 | (drop 2 [2 3 4 5 6 7]) 111 | (drop 1 [3 4 5 6 7]) 112 | (drop 0 [3 4 5 6 7]) => xs) 113 | 114 | ;; destructuring 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /one/src/one/b.clj: -------------------------------------------------------------------------------- 1 | (ns one.b) 2 | 3 | ;; expt a m => a^m 4 | ;; re-implement several clojure's functions 5 | ;; take drop zipmap map take-while drop-while... 6 | 7 | "product (x & xs) 8 | -> (x & xs) empty? -> 1 9 | -> x * product xs" 10 | 11 | (defn product 12 | [[x & xs]] 13 | (if x 14 | (* x (product xs)) 15 | 1)) 16 | 17 | "prime? -> 1 & n" "2,3,4,5,6,n-1" 18 | 19 | (defn iter-prime 20 | [n i] 21 | (cond 22 | (= n i) true 23 | (zero? (rem n i)) false 24 | :else (iter-prime n (inc i)))) 25 | 26 | (defn prime? 27 | [n] 28 | (cond (<= n 1) false 29 | (= n 2) true 30 | :else (iter-prime n 2))) 31 | 32 | (defn prime?2 33 | [n] 34 | (let [iter (fn iter [i] 35 | (cond (= n i) true 36 | (zero? (rem n i)) false 37 | :else (iter (inc i))))] 38 | (cond (<= n 1) false 39 | (= n 2) true 40 | :else (iter 2)))) 41 | 42 | (defn prime?3 43 | [n] 44 | (let [iter (fn iter [i] 45 | (cond (= n i) true 46 | (zero? (rem n i)) false 47 | :else (iter (+ i 2))))] 48 | (cond (<= n 1) false 49 | (= n 2) true 50 | (even? n) false 51 | :else (iter 3)))) 52 | 53 | (defn prime?4 54 | [n] 55 | (let [akar-n (Math/sqrt n) 56 | iter (fn iter [i] 57 | (cond (> i akar-n) true 58 | (zero? (rem n i)) false 59 | :else (iter (+ i 2))))] 60 | (cond (<= n 1) false 61 | (= n 2) true 62 | (even? n) false 63 | :else (iter 3)))) 64 | 65 | (defn fak 66 | [i] 67 | (if (<= i 1) 68 | 1 69 | (*' i (fak (dec i))))) 70 | 71 | "fak 10000 -> 1000 * fak 9999" 72 | "fak " 73 | 74 | (defn sum 75 | [[x & xs]] 76 | (if x (+' x (sum xs)) 0)) 77 | 78 | (defn sum' 79 | [lst] 80 | (loop [[x & xs] lst res 0] 81 | (if x 82 | (recur xs (+ res x)) 83 | res))) 84 | 85 | (defn jumlah-dari-0-sampe-n 86 | [n] 87 | (loop [i 0 res 0] 88 | (if (> i n) 89 | res 90 | (recur (+ i 1) (+ res i))))) 91 | 92 | "5" 93 | "loop 0 0" 94 | "loop 1 0" 95 | "loop 2 0+1" 96 | "loop 3 3" 97 | "loop 4 6" 98 | "loop 5 10" 99 | "loop 6 -> 10" 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | "48" 112 | 113 | "2 3 4 6 8 12 16 24" 114 | 115 | "a*a = 48, " 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /one/src/one/c.clj: -------------------------------------------------------------------------------- 1 | (ns one.c) 2 | 3 | ;; idiomatic clojure -> clojure & haskell 4 | 5 | ;; Higher order functions ++ list comprehensions 6 | 7 | ;; either inputnya function or output function 8 | 9 | (defn sum [[x & xs]] 10 | (if x 11 | (+ x (sum xs)) 12 | 0)) 13 | 14 | (defn product [[x & xs]] 15 | (if x 16 | (*' x (product xs)) 17 | 1)) 18 | 19 | (defn folding [f [x & xs]] 20 | (if x 21 | (f x (folding f xs)) 22 | (f))) 23 | 24 | (defn kuadratin-semua [[x & xs]] 25 | (if x 26 | (cons (* x x) (kuadratin-semua xs)) 27 | [])) 28 | 29 | (defn pangkat-tiga-in-semua [[x & xs]] 30 | (if x 31 | (cons (* x x x) (pangkat-tiga-in-semua xs)) 32 | [])) 33 | 34 | (defn f-in-semua [f [x & xs]] 35 | (if x 36 | (cons (f x) (f-in-semua f xs)) 37 | [])) 38 | 39 | ;; folding -> reduce 40 | ;; map -> the same f to all elements 41 | 42 | 43 | ;; jumlah semua kuadrat bil ganjil dari 1 - 100 44 | 45 | ;; global & local scope 46 | 47 | (def kuadrats (map #(* % %) (range 1 100))) 48 | 49 | (def memap (zipmap [:a :b :c :d :e :f :g] 50 | (range 10 20))) 51 | 52 | ;; kuadrat bilangan 1-1000 yang hasil kuadratnya itu abis dibagi 53 | ;; 19 atau 37 54 | 55 | (defn prime? 56 | [n] 57 | (->> (range 2 (inc (int (Math/sqrt n)))) 58 | (every? #(pos? (rem n %))))) 59 | 60 | 61 | ;; Outputnya function 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /one/src/one/d.clj: -------------------------------------------------------------------------------- 1 | (ns one.d) 2 | 3 | ;; pure functions => cuma depends on input 4 | ;; input yang sama => output sama 5 | ;; ga melakukan side-effects 6 | 7 | ;; impure functions => procedures 8 | 9 | (def my-value 123) 10 | 11 | (def my-var (atom 123)) 12 | 13 | ;; my-var => [] 14 | ;; (atom 'value) 15 | ;; (reset nama-atom 'value-baru) 16 | 17 | ;; jumlah 1-1000 yang kelipatan 3 or 5 18 | 19 | (defn sol1a [lim] 20 | (->> (range lim) 21 | (filter #(or (zero? (rem % 3)) (zero? (rem % 5)))) 22 | (reduce +))) 23 | 24 | (defn sol1f [lim] 25 | (->> (range lim) 26 | (keep #(when (or (zero? (rem % 3)) (zero? (rem % 5))) %)) 27 | (reduce +))) 28 | 29 | (defn sol1b [lim] 30 | (- (+ (reduce + (range 3 lim 3)) 31 | (apply + (range 5 lim 5))) 32 | (reduce + (range 15 lim 15)))) 33 | 34 | (defn sol1c [lim] 35 | (->> (for [i (range lim) 36 | :when (or (zero? (rem i 3)) (zero? (rem i 5)))] i) 37 | (reduce +))) 38 | 39 | (defn sol1d [lim] 40 | (let [sum (atom 0)] 41 | (dotimes [i lim] 42 | (if (or (zero? (rem i 3)) (zero? (rem i 5))) 43 | (reset! sum (+ @sum i)))) 44 | @sum)) 45 | 46 | (defn sol1e [lim] 47 | (loop [i 1 sum 0] 48 | (if (>= i lim) 49 | sum 50 | (if (or (zero? (rem i 3)) (zero? (rem i 5))) 51 | (recur (+ i 1) (+ sum i)) 52 | (recur (+ i 1) sum))))) 53 | 54 | (defn fibo [n] (if (<= n 1) 1 (+ (fibo (dec n)) (fibo (- n 2))))) 55 | 56 | (def mfibo (memoize (fn [n] (if (<= n 1) 1 (+ (mfibo (dec n)) (mfibo (- n 2))))))) 57 | 58 | (defn sol2a [lim] 59 | (->> (range) 60 | (map fibo) 61 | (take-while (partial > lim)) 62 | (filter even?) 63 | (reduce +) 64 | time)) 65 | 66 | (defn sol2b [lim] 67 | (->> (range) 68 | (map mfibo) 69 | (take-while (partial > lim)) 70 | (filter even?) 71 | (reduce +))) 72 | 73 | (defn lfibo [n] 74 | (->> (iterate #(let [[a b] %] [b (+' a b)]) [1 1]) 75 | (map first) 76 | (take n))) 77 | 78 | ;; fibo 10 => fibo 9 + fibo 8 79 | ;; fibo 9 => fibo 8 + fibo 7 80 | 81 | ;; pure functions => y = f (x) 82 | 83 | (defn collatz [n] 84 | (cond (== n 1) 1 85 | (even? n) (+ 1 (collatz (quot n 2))) 86 | "else" (+ 1 (collatz (+ 1 (* 3 n)))))) 87 | 88 | (defn sol14 [lim] 89 | (->> (range 1 lim) 90 | (map (juxt collatz identity)) 91 | (apply max-key first))) 92 | 93 | ;; sort-by group-by partition-by max-key merge-with 94 | ;; take-while drop-while reduce 95 | 96 | (defn ^long sol5 [^long n] 97 | (let [refs (to-array (range (inc n)))] 98 | (doseq [i (range 2 (inc n))] 99 | (let [ith (aget refs i)] 100 | (doseq [j (range (* 2 i) (inc n) i)] 101 | (aset refs j (quot (aget refs j) ith))))) 102 | (reduce * (rest (into [] refs))))) 103 | 104 | (defn ^long sol5a [^long n] 105 | (let [refs (to-array (range (inc n)))] 106 | (loop [i (int 2) res (int 1)] 107 | (if (> i n) 108 | res 109 | (let [ith (aget refs i)] 110 | (loop [j (int (* 2 i))] 111 | (when (<= j n) 112 | (aset refs j (quot (aget refs j) ith)) 113 | (recur (+ j i)))) 114 | (recur (+ i 1) (* ith res))))))) 115 | 116 | (defn solve [f & args] 117 | (dotimes [i 10] 118 | (let [res (time (apply f args))] 119 | (println res)))) 120 | 121 | (defn sol4 [lim] 122 | (->> (for [i (range 900 lim) 123 | j (range 900 i) 124 | :let [p (* i j)] 125 | :when (let [pst (seq (str p))] 126 | (= pst (reverse pst)))] p) 127 | (apply max))) 128 | -------------------------------------------------------------------------------- /pratwo/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /pratwo/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased][unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2015-12-03 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2015-12-03 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [unreleased]: https://github.com/your-name/pratwo/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/pratwo/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /pratwo/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 | -------------------------------------------------------------------------------- /pratwo/README.md: -------------------------------------------------------------------------------- 1 | # pratwo 2 | 3 | A Clojure library designed to ... well, that part is up to you. 4 | 5 | ## Usage 6 | 7 | FIXME 8 | 9 | ## License 10 | 11 | Copyright © 2015 FIXME 12 | 13 | Distributed under the Eclipse Public License either version 1.0 or (at 14 | your option) any later version. 15 | -------------------------------------------------------------------------------- /pratwo/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to pratwo 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /pratwo/project.clj: -------------------------------------------------------------------------------- 1 | (defproject pratwo "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.7.0"] 7 | [com.hypirion/primes "0.2.1"] 8 | [cheshire "5.5.0"] 9 | [danlentz/clj-uuid "0.1.6"]]) 10 | -------------------------------------------------------------------------------- /pratwo/resources/data1.json: -------------------------------------------------------------------------------- 1 | {"a":10,"b":"number","nama":"what is this","lst":[1,2,3,4,5,6]} -------------------------------------------------------------------------------- /pratwo/src/pratwo/core.clj: -------------------------------------------------------------------------------- 1 | (ns pratwo.core) 2 | 3 | (def bintang (range 100)) 4 | 5 | (defn square [x] 6 | (* x x)) 7 | 8 | (defn cube [x] 9 | (* x x)) 10 | 11 | -------------------------------------------------------------------------------- /pratwo/src/pratwo/dbase/one.clj: -------------------------------------------------------------------------------- 1 | (ns pratwo.dbase.one 2 | (:require 3 | [clj-uuid :as uuids])) 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /pratwo/src/pratwo/intermediate/recprot.clj: -------------------------------------------------------------------------------- 1 | (ns pratwo.intermediate.recprot) 2 | 3 | (defprotocol ICall 4 | (name-calling [this]) 5 | (status [this]) 6 | (say-something [this remark])) 7 | 8 | (defprotocol GetScore 9 | (score [this]) 10 | (increase [this change])) 11 | 12 | (defrecord Person [nama age score status] 13 | ICall 14 | (name-calling [this] 15 | (get this :nama)) 16 | (status [this] 17 | (get this :status)) 18 | (say-something [this remark] 19 | (str "Woi njing " remark " " (get this :nama))) 20 | 21 | GetScore 22 | (score [this] 23 | (get this :score)) 24 | (increase [this change] 25 | (+ change (get this :score)))) 26 | 27 | (defrecord Thing [nama price status] 28 | ICall 29 | (name-calling [this] 30 | (str "Ho hoi " (get this :nama))) 31 | (status [this] 32 | (get this :status)) 33 | (say-something [this remark] 34 | (str remark " " (get this :nama)))) 35 | -------------------------------------------------------------------------------- /pratwo/src/pratwo/intermediate/stm.clj: -------------------------------------------------------------------------------- 1 | (ns pratwo.intermediate.stm) 2 | 3 | (def something (range 10)) 4 | 5 | (defonce someone "joni") 6 | 7 | ;; Atom <- easiest one 8 | 9 | (defonce some-number (atom 0)) 10 | 11 | ;; Processor 2cores/4cores/8cores 12 | 13 | ;; Ref => more sophiscated 14 | 15 | (defonce a-ref (ref 0)) 16 | 17 | (defn prime? 18 | [^long p] 19 | (cond 20 | (< p 2) false 21 | (== p 2) true 22 | (even? p) false 23 | :else (->> (range 3 (inc (int (Math/sqrt p)))) 24 | (map #(rem p %)) 25 | (every? pos?)))) 26 | 27 | (defn sum-primes 28 | [^long lim] 29 | (->> (range (inc lim)) 30 | (filter prime?) 31 | (reduce +))) 32 | 33 | (defonce scores 34 | (atom (for [i (range 200000)] 35 | {:nama (str "joni-" i) 36 | :score (rand-int 100)}))) 37 | 38 | (defn sorter [] 39 | (loop [] 40 | (reset! scores (sort-by :score @scores)) 41 | (println (take 10 @scores)) 42 | (do (Thread/sleep 5000) 43 | (recur)))) 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /pratwo/src/pratwo/intermediate/trans.clj: -------------------------------------------------------------------------------- 1 | (ns pratwo.intermediate.trans) 2 | 3 | (defn prime? 4 | [^long p] 5 | (cond 6 | (< p 2) false 7 | (== p 2) true 8 | (even? p) false 9 | :else (->> (range 3 (inc (int (Math/sqrt p)))) 10 | (map #(rem p %)) 11 | (every? pos?)))) 12 | 13 | 14 | -------------------------------------------------------------------------------- /pratwo/src/pratwo/json/one.clj: -------------------------------------------------------------------------------- 1 | (ns pratwo.json.one 2 | (:require 3 | [cheshire.core :as cc])) 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /pratwo/src/pratwo/one.clj: -------------------------------------------------------------------------------- 1 | (ns pratwo.one 2 | (:require 3 | [pratwo.core :as co] 4 | [clojure.string :as cs] 5 | [clojure.java.io :as io] 6 | [clojure.set :as st])) 7 | 8 | (defn mapin 9 | [num] 10 | (map co/square (range num))) 11 | -------------------------------------------------------------------------------- /pratwo/src/pratwo/prime/one.clj: -------------------------------------------------------------------------------- 1 | (ns pratwo.prime.one 2 | (:require [com.hypirion.primes :as p])) 3 | 4 | 5 | -------------------------------------------------------------------------------- /pratwo/src/pratwo/stat.clj: -------------------------------------------------------------------------------- 1 | (ns pratwo.stat) 2 | 3 | (defn freq 4 | ([lst] 5 | (frequencies lst)) 6 | ([lst ks] 7 | (->> (map #(select-keys % ks) lst) 8 | (map #(frequencies (val %))) 9 | (zipmap ks)))) 10 | 11 | (defn mean 12 | [lst] 13 | (double (/ (reduce + lst) (count lst)))) 14 | 15 | (defn prime? 16 | [p] 17 | (cond (< p 2) false 18 | (== p 2) true 19 | (even? p) false 20 | :else (->> (range 3 (inc (Math/sqrt p)) 2) 21 | (every? #(pos? (rem p %)))))) -------------------------------------------------------------------------------- /pratwo/src/pratwo/two.clj: -------------------------------------------------------------------------------- 1 | (ns pratwo.two 2 | (:require 3 | [pratwo.core :refer :all] 4 | [pratwo.one :refer [mapin] :as one])) 5 | 6 | (defn another-one 7 | [] 8 | (mapin 10)) 9 | 10 | (defn pake-one 11 | [] 12 | (one/mapin 10)) 13 | 14 | (defn semua [] 15 | (+ (cube 100) (square 20))) 16 | -------------------------------------------------------------------------------- /pratwo/test/pratwo/stat.clj: -------------------------------------------------------------------------------- 1 | (ns pratwo.stat 2 | (:require 3 | [clojure.test :refer :all] 4 | [pratwo.stat :refer :all])) 5 | 6 | (deftest testing-freq 7 | (is (= 2 (+ 1 1))) 8 | (is (= 10 (reduce + (range 5)))) 9 | (is (= {10 1 12 2} (freq [10 12 12]))) 10 | (is (== 2 (mean (repeat 10 2)))) 11 | (testing "prime function" 12 | (is (= false (prime? -2))) 13 | (is (= true (prime? 2))) 14 | (is (= [] (filter prime? (range 4 100 2)))) 15 | (is (= [3 5 7 11 13 17 19] 16 | (filter prime? (range 3 20 2)))))) 17 | -------------------------------------------------------------------------------- /proone/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /proone/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 | -------------------------------------------------------------------------------- /proone/README.md: -------------------------------------------------------------------------------- 1 | # proone 2 | 3 | A Clojure library designed to ... well, that part is up to you. 4 | 5 | ## Usage 6 | 7 | FIXME 8 | 9 | ## License 10 | 11 | Copyright © 2015 FIXME 12 | 13 | Distributed under the Eclipse Public License either version 1.0 or (at 14 | your option) any later version. 15 | -------------------------------------------------------------------------------- /proone/dev/user.clj: -------------------------------------------------------------------------------- 1 | (ns user 2 | (:require [clojure.string :as cs])) 3 | 4 | (def users 5 | (atom ["skadinyo" "0dsapoetra" "beleje" "calvin91" "awol" "leledumbo" "wisnuops" "dizqar" 6 | "pelaut" "neilt" "azrax" "codxse" "gilangardya" "dhiamonkey"])) 7 | 8 | (defn progress [nama] 9 | (let [res (-> (slurp (str "http://www.4clojure.com/user/" nama)) 10 | (cs/split #"/156") 11 | first)] 12 | (subs res (- (count res) 2)))) 13 | 14 | (defn all [] 15 | (doseq [nama @users] 16 | (println (str "Ucil : " nama)) 17 | (println (str "Progress : " (progress nama))) 18 | (println "---------------------"))) 19 | -------------------------------------------------------------------------------- /proone/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to proone 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /proone/project.clj: -------------------------------------------------------------------------------- 1 | (defproject proone "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.7.0"] 7 | [hiccup "1.0.5"]] 8 | :profiles {:dev {:source-paths ["dev"]}}) 9 | -------------------------------------------------------------------------------- /proone/resources/gogom.edn: -------------------------------------------------------------------------------- 1 | [1 2 3 4 5] -------------------------------------------------------------------------------- /proone/resources/one.html: -------------------------------------------------------------------------------- 1 | 2 | this title

Hello someone you know

This is the link

-------------------------------------------------------------------------------- /proone/src/proone/alfa.clj: -------------------------------------------------------------------------------- 1 | (ns proone.alfa 2 | (:require 3 | [proone.core :as c ] 4 | [hiccup.core :refer [h html]] 5 | [hiccup.page :refer [html5]])) 6 | 7 | (defn mukain [x] 8 | (c/mapi (str (c/cube x)))) 9 | 10 | (defn home-page 11 | [somebody-to-lo-what-to-lo] 12 | (html5 13 | [:head 14 | [:title "this title"]] 15 | [:body 16 | [:div 17 | [:center 18 | [:h1 (str "Hello " somebody-to-lo-what-to-lo)] 19 | [:h1 [:a {:href "http://zenius.net"} 20 | "This is the link"]]]]])) 21 | 22 | (defn pangkat 23 | [x] 24 | (if (zero? x) 25 | (fn [a] 1) 26 | (fn [a] (* a ((pangkat (dec x)) a))))) 27 | 28 | (defn expt 29 | [a m] 30 | (if (zero? m) 31 | 1 32 | (* a (expt a (dec m))))) 33 | 34 | (defn sum-primes 35 | [lim] 36 | (->> (range 3 (+ lim 1) 2) 37 | (filter #(every? (fn [x] (pos? (rem % x))) 38 | (range 3 (inc (Math/sqrt %))))) 39 | (reduce +) 40 | (+ 2))) 41 | 42 | (defn sum-primes' 43 | [lim] 44 | (->> (transduce 45 | (filter #(every? (fn [x] (pos? (rem % x))) 46 | (range 3 (inc (Math/sqrt %))))) 47 | + (range 3 (+ lim 1) 2)) 48 | (+ 2))) 49 | 50 | (defn ^long sum-sieve 51 | [^long lim] 52 | (let [primes (boolean-array (+ lim 1) true) 53 | llim (+ 1 (int (Math/sqrt lim)))] 54 | (loop [i (int 3) res (int 2)] 55 | (if (>= i lim) 56 | res 57 | (if (<= i llim) 58 | (if (aget primes i) 59 | (do (loop [j (int (* i i))] 60 | (when (<= j lim) 61 | (aset primes j false) 62 | (recur (+ j i i)))) 63 | (recur (+ i 2) (+ res i))) 64 | (recur (+ i 2) res)) 65 | (if (aget primes i) 66 | (recur (+ i 2) (+ res i)) 67 | (recur (+ i 2) res))))))) 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /proone/src/proone/core.clj: -------------------------------------------------------------------------------- 1 | (ns proone.core 2 | (:require 3 | [clojure.set :as cs :refer [difference intersection]] 4 | [clojure.string :as st :refer :all])) 5 | 6 | (defn cube [x] 7 | (* x x x)) 8 | 9 | (defn mapi [x] 10 | (str x "asdxdsa" (apply str (reverse x)))) 11 | -------------------------------------------------------------------------------- /proone/src/proone/tfor.clj: -------------------------------------------------------------------------------- 1 | (ns proone.tfor) 2 | 3 | ;; judulin : list comprehension 4 | 5 | (defn foo-one [n] 6 | (for [i (range n) 7 | j (range i n) 8 | :while 9 | :let [isqr (* i i)]] 10 | [i isqr j])) 11 | 12 | (defn pita [lim] 13 | (for [a (range 3 lim) 14 | b (range a lim) 15 | :let [asqr (* a a) 16 | bsqr (* b b) 17 | csqr (+ asqr bsqr) 18 | c (Math/sqrt csqr)] 19 | :when (= (Math/floor c) 20 | (Math/ceil c))] 21 | [a b (int c)])) 22 | 23 | 24 | -------------------------------------------------------------------------------- /proone/test/proone/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns proone.core-test 2 | (:require [clojure.test :refer :all] 3 | [proone.core :refer :all])) 4 | 5 | (deftest a-test 6 | (testing "FIXME, I fail." 7 | (is (= 0 1)))) 8 | -------------------------------------------------------------------------------- /sscom/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /sscom/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 | -------------------------------------------------------------------------------- /sscom/README.md: -------------------------------------------------------------------------------- 1 | # sscom 2 | 3 | A Clojure library designed to ... well, that part is up to you. 4 | 5 | ## Usage 6 | 7 | FIXME 8 | 9 | ## License 10 | 11 | Copyright © 2015 FIXME 12 | 13 | Distributed under the Eclipse Public License either version 1.0 or (at 14 | your option) any later version. 15 | -------------------------------------------------------------------------------- /sscom/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to sscom 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /sscom/project.clj: -------------------------------------------------------------------------------- 1 | (defproject sscom "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.7.0"] 7 | [http-kit "2.1.18"] 8 | [ring "1.4.0"] 9 | [ring/ring-defaults "0.1.5"] 10 | [lib-noir "0.9.9"] 11 | [com.ashafa/clutch "0.4.0"] 12 | [selmer "0.9.1"] 13 | [couchbase-clj "0.2.0"] 14 | [com.stuartsierra/component "0.3.0"]] 15 | :main sscom.core) 16 | -------------------------------------------------------------------------------- /sscom/resources/config.edn: -------------------------------------------------------------------------------- 1 | {:port 3000 2 | :db {:bucket "play" 3 | :uris ["http://127.0.0.1:8091/pools"]} 4 | :public-directory "/public"} 5 | -------------------------------------------------------------------------------- /sscom/src/sscom/core.clj: -------------------------------------------------------------------------------- 1 | (ns sscom.core 2 | (:require [sscom.system :as system])) 3 | 4 | (defn -main [& args] 5 | (system/init) 6 | (system/start)) 7 | -------------------------------------------------------------------------------- /sscom/src/sscom/dbase.clj: -------------------------------------------------------------------------------- 1 | (ns sscom.dbase 2 | (:require 3 | [couchbase-clj.client :as couch] 4 | [com.stuartsierra.component :as component])) 5 | 6 | (defrecord Database [uris bucket] 7 | component/Lifecycle 8 | (start [this] 9 | (assoc this 10 | :connection 11 | (couch/create-client {:uris uris :bucket bucket}))) 12 | (stop [this] 13 | (couch/shutdown (:connection this)) 14 | (dissoc this :connection))) 15 | 16 | (defn create [uris bucket] 17 | (map->Database {:uris uris :bucket bucket})) 18 | 19 | 20 | -------------------------------------------------------------------------------- /sscom/src/sscom/routes.clj: -------------------------------------------------------------------------------- 1 | (ns sscom.routes 2 | (:require 3 | [compojure.core :refer [routes GET POST]] 4 | [compojure.route :refer [resources not-found]] 5 | [com.stuartsierra.component :as component])) 6 | 7 | (declare all-articles main-routes misc-routes all-routes) 8 | 9 | (defrecord Routes [database public-directory] 10 | component/Lifecycle 11 | (start [this] 12 | (assoc this 13 | :tabel (all-routes database public-directory))) 14 | (stop [this] 15 | this)) 16 | 17 | (defn create 18 | [public-directory] 19 | (component/using 20 | (map->Routes {:public-directory public-directory}) 21 | [:database])) 22 | 23 | ;; These are all private functions 24 | 25 | (defn- all-articles [database] 26 | {:boongan "this is a boongan"}) 27 | 28 | (defn- main-routes [database] 29 | (routes 30 | (GET "/" request 31 | "Say hi") 32 | (GET "/articles" request 33 | (all-articles database)))) 34 | 35 | (defn- misc-routes [public-directory] 36 | (routes 37 | (resources public-directory) 38 | (not-found "Not found boy"))) 39 | 40 | (defn- all-routes 41 | [database public-directory] 42 | (routes (main-routes database) 43 | (misc-routes public-directory))) 44 | -------------------------------------------------------------------------------- /sscom/src/sscom/server.clj: -------------------------------------------------------------------------------- 1 | (ns sscom.server 2 | (:require 3 | [org.httpkit.server :as http] 4 | [ring.middleware.defaults :refer [wrap-defaults site-defaults]] 5 | [com.stuartsierra.component :as component])) 6 | 7 | (defrecord Server [routes port] 8 | component/Lifecycle 9 | (start [this] 10 | (let [app (wrap-defaults (:tabel routes) site-defaults)] 11 | (assoc this 12 | :stop-fn 13 | (http/run-server app {:port port})))) 14 | (stop [this] 15 | ((:stop-fn this)) 16 | (dissoc this :stop-fn))) 17 | 18 | (defn create [port] 19 | (-> (map->Server {:port port}) 20 | (component/using [:routes]))) 21 | 22 | -------------------------------------------------------------------------------- /sscom/src/sscom/system.clj: -------------------------------------------------------------------------------- 1 | (ns sscom.system 2 | (:require 3 | [com.stuartsierra.component :as component] 4 | [sscom.dbase :as db] 5 | [sscom.routes :as routes] 6 | [sscom.server :as server] 7 | [clojure.tools.namespace.repl :refer [refresh]])) 8 | 9 | (defn create-system 10 | [config-file] 11 | (let [{:keys [port db public-directory]} 12 | (->> config-file slurp read-string) 13 | {:keys [uris bucket]} db] 14 | (component/system-map 15 | :database (db/create uris bucket) 16 | :routes (routes/create public-directory) 17 | :server (server/create port)))) 18 | 19 | (def conf "resources/config.edn") 20 | 21 | (defonce system (create-system conf)) 22 | 23 | (defn init [] 24 | "Function to initiate the system" 25 | (alter-var-root 26 | #'system 27 | (constantly (create-system conf)))) 28 | 29 | (defn start 30 | "Function to start the system, that is starting all the components and resolving 31 | the dependencies of each component." 32 | [] 33 | (alter-var-root 34 | #'system 35 | component/start)) 36 | 37 | (defn stop 38 | "Function to stop the system, and stop all of its components according to the 39 | dependencies of each component." 40 | [] 41 | (alter-var-root 42 | #'system 43 | (fn [s] (component/stop s)))) 44 | 45 | (defn go 46 | "The function to be called from the REPL for starting the system" 47 | [] 48 | (init) 49 | (start) 50 | system) 51 | 52 | (defn reset 53 | "Reset the system in REPL after changing some codes" 54 | [] 55 | (stop) 56 | (refresh :after 'sscom.system/go)) -------------------------------------------------------------------------------- /sscom/test/sscom/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns sscom.core-test 2 | (:require [clojure.test :refer :all] 3 | [sscom.server :refer :all])) 4 | 5 | (deftest a-test 6 | (testing "FIXME, I fail." 7 | (is (= 0 1)))) 8 | -------------------------------------------------------------------------------- /tutone/project.clj: -------------------------------------------------------------------------------- 1 | (defproject tutone "0.0.1-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :dependencies [[org.clojure/clojure "1.7.0"]] 4 | :javac-options ["-target" "1.8" "-source" "1.8" "-Xlint:-options"] 5 | :aot [tutone.core] 6 | :main tutone.core) 7 | -------------------------------------------------------------------------------- /tutone/src/tutone/a.clj: -------------------------------------------------------------------------------- 1 | (ns tutone.core) 2 | 3 | (def mvec [1 2 3 4 5 6 7]) 4 | 5 | (def mlist (range 1 20 2)) 6 | 7 | (def people-in-mylife {:nama "bokir" :julukan "Joni"}) 8 | 9 | (defn square [x] (* x x)) 10 | 11 | (defn cube 12 | [x] 13 | (* x x x)) 14 | 15 | ;; Ini komen sesuatu yang ga dibaca sama clojure... 16 | 17 | ;; eh ini belom beres masih error 18 | 19 | (defn pk 20 | [a b c] 21 | (fn [x] 22 | (+ (* a (square x)) 23 | (* b x) 24 | c))) 25 | 26 | (defn mutlak 27 | [x] 28 | (if (pos? x) x (- x))) 29 | 30 | (defn apanih? 31 | [x] 32 | (if (> x 0) 33 | "positive" 34 | (if (= x 0) "enol" "negatip"))) 35 | 36 | (defn apanih?part2 37 | [x] 38 | (cond 39 | (> x 0) "positive" 40 | (= x 0) "enol" 41 | (< x -5) "negatip" 42 | :else "ga mungkin")) 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | --------------------------------------------------------------------------------