Skip to content

Instantly share code, notes, and snippets.

(doseq [[printer {:keys [id sub-ids]}] {(partial println "sub1") {:id :A :sub-ids [11 12 13 14]}
(partial println "sub2") {:id :B :sub-ids []}}
sub-id sub-ids
:let [sub-id-times-2 (do (println "binding occured") (* sub-id 2))]]
(printer id sub-id))
;;; binding occured
;;; sub1 :A 11
;;; binding occured
;;; sub1 :A 12
(doseq [[printer {:keys [id sub-ids]}] {(partial println "sub1") {:id :A :sub-ids [11 12 13 14]}
(partial println "sub2") {:id :B :sub-ids [21 22 23 24]}}
:let [id-str (do (println id) (name id))]
sub-id sub-ids]
(printer id-str sub-id))
;;; :A
;;; sub1 A 11
;;; sub1 A 12
;;; sub1 A 13
(doseq [[printer {:keys [id sub-ids]}] {(partial println "sub1") {:id :A :sub-ids [11 12 13 14]}
(partial println "sub2") {:id :B :sub-ids [21 22 23 24]}}
sub-id sub-ids]
(let [id-str (name id)]
(printer id-str sub-id)))
(doseq [[printer {:keys [id sub-ids]}] {(partial println "sub1") {:id :A :sub-ids [11 12 13 14]}
(partial println "sub2") {:id :B :sub-ids [21 22 23 24]}}]
(let [id-str (name id)]
(doseq [sub-id sub-ids]
(printer id-str sub-id))))
;;; -output-
;;; sub1 A 11
;;; sub1 A 12
;;; sub1 A 13
;;; justification: http://en.wikipedia.org/wiki/%E2%88%98
(eval-after-load 'clojure-mode
'(font-lock-add-keywords
'clojure-mode `(("(\\(comp\\)[[:space:]]"
(0 (progn (compose-region (match-beginning 1)
(match-end 1) "∘")
nil))))))
;;;; created by David Chelimsky
(ns leiningen.hooks.expand-resource-paths
(:use [clojure.java.io :only [as-file]])
(:import [java.io File])
(:require [robert.hooke]
[leiningen.javac]
[org.satta.glob :as glob]))
(defun char-at-point ()
(interactive)
(buffer-substring-no-properties (point) (+ 1 (point))))
(defun clj-string-name (s)
(substring s 1 -1))
(defun clj-keyword-name (s)
(substring s 1))
(defn in-context
"rebind a var, expecations are run in the defined context"
{:expectations-options :in-context}
[work]
(with-redefs [some-src/a-fn-to-be-rebound (constantly :a-rebound-val)]
(work)))
(defun switch-to-grep ()
(interactive)
(switch-to-buffer-other-window "*grep*"))
(defun grep-string-in (s project-root)
(interactive (list (read-string "string: ")
(read-directory-name
"Project Root: "
(locate-dominating-file default-directory "project.clj"))))
(message (concat s project-root))
(let* ((cmd (concat "grep -nH -e " s " -R " project-root)))
(setq last-run-grep cmd)
(grep cmd)))