5.7 KiB
5.7 KiB
In [8]:
(def lst [1 2 3 4 5 6 7 8])
(defn times-2 [n]
(* 2 n))
(def lst-2 (map times-2 lst))Out [8]:
#'user/lst-2
In [6]:
(def all-numbers (range))
(def all-even-numbers (map times-2 all-numbers))
(take 10 all-even-numbers)Out [6]:
(0 2 4 6 8 10 12 14 16 18)
In [36]:
(def foo 2) ;; this is a comment. We call it a "line comment"
(comment (println "This is what we call a block comment, rarely used"))
#_(println "This is another type of block comment, more often used. (used by david nolen)")In [14]:
(defn print-odd-or-even [n]
(if (odd? n)
(println n " is odd")
(println n " is even")))Out [14]:
#'user/print-odd-or-even
In [32]:
(require '[clojupyter.misc.display :as display]) ;; https://github.com/clojupyter/clojupyterIn [38]:
(display/html "<h3>We can very easely print stuff from code</h3>") Out [38]:
We can very easely print stuff from code
In [43]:
(defn html-h1 [title])Out [43]:
#'user/html-h1
In [42]:
(display/hiccup-html [:h3 "hiccup is much better"])Out [42]:
hiccup is much better
In [45]:
(defn hiccup-h1 [title])Out [45]:
#'user/hiccup-h1
In [ ]:
(def dodgeball-data
[{:team-1 :drummonville :team-2 :montreal :points-1 4 :points-1 5}
{:team-1 :drummonville :team-2 :montreal :points-1 4 :points-1 5}
{:team-1 :drummonville :team-2 :montreal :points-1 4 :points-1 5}
{:team-1 :drummonville :team-2 :montreal :points-1 4 :points-1 5}])