Skip to content

Instantly share code, notes, and snippets.

View d11wtq's full-sized avatar

Chris Corbyn d11wtq

  • Melbourne, Australia
View GitHub Profile
(ns example.factory.aws.cloudformation
(:require [clojure.data.json :as json]))
(defn apply-stack-fn
[create-fn update-fn]
(fn apply-stack
[payload]
(try
(create-fn payload)
(catch AlreadyExistsException e
@d11wtq
d11wtq / README.md
Last active August 29, 2015 14:20
Writing int->str (Clojure)

int->str

This function computes the English string for any given integer supported by Clojure.

Example

(int->str 110917) ; "one hundred and ten thousand nine hundred and seventeen"
@d11wtq
d11wtq / atbash.clj
Last active August 29, 2015 14:21
Atbash Cipher in Clojure
(ns atbash.core
(require [clojure.string :refer [join lower-case]]))
(def lookup
(let [alphabet "abcdefghijklmnopqrstuvwxyz"]
(zipmap alphabet (reverse alphabet))))
(defn encode
[s]
(->> (lower-case s)
@d11wtq
d11wtq / declare.clj
Last active August 29, 2015 14:21
Implicit forward declarations for Clojure
(defn def?
[[a b]]
(if (#{'defn 'def} a) b))
(defmacro progn
[& sexps]
(let [names (->> sexps (filter def?) (map def?))]
`(do
(declare ~@names)
~@sexps)))
@d11wtq
d11wtq / roman.clj
Last active August 29, 2015 14:22
Roman numerals
(ns roman.core)
(defmacro defpairs
"Helper macro to make ordered defs for pairs nicer."
[varname pairs]
`(def ~varname
(partition 2 ~pairs)))
(defpairs digits
["M" 1000