This file contains hidden or 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 | |
(:b (DefaultMap. :foo {:a 1})) | |
; => :foo | |
(:a (DefaultMap. :foo {:a 1})) | |
; => 1 | |
(merge-with conj (DefaultMap. [] {}) {:a 1} {:a 2} {:a 3}) | |
; => {:a [1 2 3]} | |
) | |
;;; method implementations basically taken from clojure.core/emit-defrecord |
This file contains hidden or 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
;;; All Kinds of Destructuring ;;; | |
(let [foo 1] foo) | |
; => 1 | |
(let [[foo bar] [1 2 3]] [foo bar]) | |
; => [1 2] | |
(let [[foo bar & baz] [1 2 3]] [foo bar baz]) | |
; => [1 2 (3)] |
This file contains hidden or 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 fn-pre-post | |
(:refer-clojure :exclude (defn fn defn-))) | |
(clojure.core/defn- insert-arg | |
"Insert arg in the second position of the form cond." | |
[arg cond] | |
(cons (first cond) (cons arg (rest cond)))) | |
(clojure.core/defn- parse-params | |
"Parse a parameter vector, possibly containing nested vectors for |
This file contains hidden or 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
;; this file is a walkthrough of Moustache features, a web framework for Clojure | |
;; http://github.com/cgrand/moustache/tree/master | |
;; Moustache allows to declare routes, apply middlewares and dispatch on http methods. | |
;; Moustache is compatible with all frameworks built on Ring, including Compojure | |
(ns demo | |
(:use net.cgrand.moustache) | |
(:use [ring.adapter.jetty :only [run-jetty]])) ;; hmmm Ring without servlets | |
NewerOlder