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
(defmacro lazy | |
"Returns a lazy sequence of calls to (f). Arguments are evaluated once as needed. | |
(lazy f a b c d) --> (a, (f a b), (f (f a b) c), (f (f (f a b) c) d))" | |
([f x] | |
`(lazy-seq | |
(list ~x)) ) | |
([f x form & more] | |
`(lazy-seq | |
(let [x# ~x] | |
(cons x# |
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
; Experiment with 'foo' blocks as an alternative to -> and ->>. | |
(defmacro foo | |
([] '%) | |
([form & more] | |
`(let [~'% ~form] (foo ~@more))) ) | |
(def foo-ex1 | |
(foo | |
1 | |
(+ 1 %) |
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
(defmacro topic | |
([t] nil) | |
([t form] form) | |
([t form & more] | |
`(let [~t ~form] (topic ~t ~@more))) ) | |
(def topic-ex1 | |
(topic % 1 | |
(+ 1 %) | |
(/ % 2) ) ) |
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
#!/bin/bash -e | |
new_status() | |
{ | |
gajim-remote change_status "$@" | |
} | |
lock_screen() | |
{ | |
gnome-screensaver-command --lock |
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
(defmacro let2 | |
"Alternate let block that doesn't have a body, just bindings. The last binding is returned." | |
([] nil) | |
([& bindings] | |
`(let [~@bindings] ~(first (take-last 2 bindings))) ) ) |
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 conjoin [& preds] | |
(fn [& args] | |
(let2 | |
% (apply juxt preds) | |
% (map % args) | |
% (flatten %) | |
% (every? identity %)))) | |
(defn disjoin [& preds] | |
(fn [& args] |
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
#!/bin/bash -e | |
status_icon_000="/usr/share/icons/Humanity/apps/48/stock_delete-bookmark.svg" | |
status_icon_100="/usr/share/icons/Humanity/apps/48/stock_bookmark.svg" | |
function context_loop() { | |
declare time_task | |
while time_task=$(context_switch_dialog $*) | |
do | |
set $time_task # reference using positional args |
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 sparkline [values] | |
(let [low (apply min values) | |
high (apply max values) | |
bars "▁▂▃▄▅▆▇█" | |
step (/ (- high low) (dec (count bars))) | |
scale #(nth bars (int (/ (- % low) step)))] | |
(apply str (map scale values)))) |
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 deftype+ | |
"Augmented deftype sporting a new :delegate option.") | |
;; code to get the methods of interfaces and protocols | |
(defmulti get-methods | |
"Return a map of all method names to their arity." | |
class) | |
(defmethod get-methods clojure.lang.PersistentArrayMap | |
[protocol] |
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 squarespec | |
(:require [clojure.spec :as s] | |
[clojure.spec.gen :as sgen] | |
[clojure.spec.test :as stest])) | |
;; Implementation | |
(defn square | |
"Define a square path given an origin and length." | |
[[x1 y1 :as origin] length] | |
(let [x2 (+ x1 length) |
OlderNewer