This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn do-something | |
([] "nothing") | |
([one] "easy!") | |
([one two] "hm, ok, will do") | |
([one two & more] "oh, no, so many!")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn add-up | |
"takes initial value and collection, | |
returns sum of value and collection's all element" | |
([val coll] | |
(let [_ (println (str "val: " val ", coll: " coll))] | |
(cond | |
(empty? coll) val | |
:else (add-up (+ val (first coll)) (rest coll)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(comment | |
;; The first version of main function. | |
;; TODO delete if a new version completes. | |
(defn -main [] | |
"I can say 'Hello World'." | |
(println "Hello, World!")) | |
) | |
(defn hello-world [] (println "Hello, World!")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject hello-hiccup "0.1.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:url "http://example.com/FIXME" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:dependencies [[org.clojure/clojure "1.5.1"] | |
[hiccup "1.0.5"]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns hello-hiccup.core | |
(:use [hiccup.core])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(declare incrementor decrementor) | |
(defn incrementor [n] | |
(let [_ (print (str n ", ")) | |
next-val (+ n (rand-int 100))] | |
(if (< -10000 next-val) | |
(decrementor next-val)))) | |
(defn decrementor [n] | |
(let [_ (print (str n ", ")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(declare incrementor2 decrementor2) | |
(defn incrementor2 [n] | |
(let [_ (print (str n ", ")) | |
next-val (+ n (rand-int 100))] | |
(if (< -10000 next-val) | |
#(decrementor2 next-val)))) | |
(defn decrementor2 [n] | |
(let [_ (print (str n ", ")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn right-and-left [size] | |
(letfn | |
[(go-right [x [start end]] | |
(cond | |
(< (inc x) end) (do #_(println "right") (go-right (inc x) [start end])) | |
(> (dec x) start) (go-left x [start (dec end)]) | |
:else (println "done"))) | |
(go-left [x [start end]] | |
(cond | |
(> (dec x) start) (do #_(println "left") (go-left (dec x) [start end])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn question [she he] | |
(let [hers (str she "'s") | |
his (str he "'s")] | |
(str "Hey " she ", are " hers " and " his " the same?"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn right-triangle? [coll] | |
(let [a-square (* (nth coll 0) (nth coll 0)) | |
b-square (* (nth coll 1) (nth coll 1)) | |
c-square (* (nth coll 2) (nth coll 2))] | |
(= (+ a-square b-square) c-square))) | |
(right-triangle? [1 2 3]) |
OlderNewer