Skip to content

Instantly share code, notes, and snippets.

;;; Example from compojure rewritten for use with webpub.
;;; Look no dependencies!
(ns example)
(defn html-doc
[title & body]
[:html
[:head
[:title title]]
(define-class-ai druid
(spell moonfire "moonfire")
(spell roots "roots")
(spell wrath "wrath")
(spell mark-of-the-wild "mark of the wild")
(spell thorns "thorns")
(spell rejuvenate "rejuvenation")
(spell regrowth "regrowth")
;; Feral
(spell dire-bear "dire bear")
(defn Y [r] (#(% %) #(r (fn [x] ((% %) x)))))
(defn fact-gen [fact-in]
(fn [n]
(if (= n 0) 1
(* n (fact-in (- n 1))))))
((Y fact-gen) 7)
(ns net.cddr.rabbitmq
(:import (com.rabbitmq.client Channel Connection ConnectionFactory
QueueingConsumer
RpcClient StringRpcServer)
(com.rabbitmq.tools.jsonrpc JsonRpcServer JsonRpcClient)
(com.rabbitmq.examples HelloJsonService)))
;; (import '(com.rabbitmq.client Channel Connection ConnectionFactory
;; QueueingConsumer
;; My take on Fibonacci numbers
(defn gen-fibo []
(let [fibo (atom nil)]
(reset! fibo (lazy-cat [0 1] (lazy-seq (map + @fibo (rest @fibo)))))))
(def fib (proxy [clojure.lang.Seqable] []
(seq [] (gen-fibo))))