Add first cut at Java interop
This commit is contained in:
parent
d7d54f1a08
commit
fb3f05e2c6
16
src/koans/java_interop.clj
Normal file
16
src/koans/java_interop.clj
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
(meditations
|
||||||
|
"You may have done more with Java than you know"
|
||||||
|
(= __ (class "warfare")) ; hint: try typing (javadoc "warfare") in the REPL
|
||||||
|
|
||||||
|
"The dot signifies easy and direct Java interoperation"
|
||||||
|
(= __ (.toUpperCase "select * from"))
|
||||||
|
|
||||||
|
"But instance method calls are very different from normal functions"
|
||||||
|
(= ["SELECT" "FROM" "WHERE"] (map ___ ["select" "from" "where"]))
|
||||||
|
|
||||||
|
"Constructing might be harder than breaking"
|
||||||
|
(= 10 (let [latch (java.util.concurrent.CountDownLatch. __)]
|
||||||
|
(.getCount latch)))
|
||||||
|
|
||||||
|
"Static methods are slashing prices!"
|
||||||
|
(== __ (Math/pow 2 10)))
|
@ -192,7 +192,18 @@
|
|||||||
nil
|
nil
|
||||||
[true false]
|
[true false]
|
||||||
(str "Congratulations on your Best Picture Oscar, "
|
(str "Congratulations on your Best Picture Oscar, "
|
||||||
"Evil Alien Conquerors!")]}})
|
"Evil Alien Conquerors!")]}
|
||||||
|
|
||||||
|
"java_interop" {"__" ['java.lang.String
|
||||||
|
"SELECT * FROM"
|
||||||
|
10
|
||||||
|
1024
|
||||||
|
]
|
||||||
|
"___" ['#(.toUpperCase %)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
(defn replace-with [s k replacements]
|
(defn replace-with [s k replacements]
|
||||||
(let [unreplaced-texts (split s (re-pattern (str "\\b" k "\\b")))]
|
(let [unreplaced-texts (split s (re-pattern (str "\\b" k "\\b")))]
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
"refs"
|
"refs"
|
||||||
"atoms"
|
"atoms"
|
||||||
"macros"
|
"macros"
|
||||||
"datatypes"])
|
"datatypes"
|
||||||
|
"java_interop"])
|
||||||
|
|
||||||
(defn ordered-koan-paths []
|
(defn ordered-koan-paths []
|
||||||
(map (fn [koan-name]
|
(map (fn [koan-name]
|
||||||
|
Loading…
Reference in New Issue
Block a user