Skip to content

Instantly share code, notes, and snippets.

View fdserr's full-sized avatar

fdserr fdserr

View GitHub Profile
@fdserr
fdserr / extract-all-with
Created August 16, 2013 15:17
Kind of split-with, but fn is applied only once, so side-effects are okay : (extract-all-with [1 2 3 4 5 6] #(when (odd? %) (* 2 %))) -> [[2 6 10] [2 4 6]]
(defn extract-all-with
"=> (extract-all-with [1 2 3 4 5 6] #(when (odd? %) (* 2 %)))
[[2 6 10] [2 4 6]]"
([coll fun]
(extract-all-with coll fun (transient []) (transient [])))
([coll fun applied not-applied]
(if-not (seq coll)
[(persistent! applied) (persistent! not-applied)]
(if-let
[x (fun (first coll))]
@fdserr
fdserr / extract-one-with
Created August 16, 2013 15:40
Extract / remove once / remove one instance (no split-with mangling, side-effecting okay): (extract-one-with [12 2 3 4 5 6] #(when (odd? %) (* 2 %)) -> [[6] [12 2 4 5 6]]
(defn extract-one-with
"=> (extract-one-with [12 2 3 4 5 6] #(when (odd? %) (* 2 %)))
[[6] [12 2 4 5 6]]"
([coll fun]
(extract-one-with coll fun [] []))
([coll fun applied not-applied]
(if-not (seq coll)
[applied not-applied]
(if-let
[x (fun (first coll))]
@fdserr
fdserr / cljs-debug-macros.clj
Created October 5, 2015 13:44 — forked from michaelsbradleyjr/cljs-debug-macros.clj
Macros and functions which facilitate the development and debugging of other macros and their supporting functions within a ClojureScript project.
(ns my-cljs.macros.debug
(:require [cljs.analyzer :as cljs]
clojure.walk))
(declare ap
cljs-macroexpand*
cljs-macroexpand-1*
cljs-macroexpand-all*
cljs-macroexpand
@fdserr
fdserr / atom_clojure_setup.md
Created July 8, 2017 02:39 — forked from jasongilman/atom_clojure_setup.md
This describes how I setup Atom for Clojure Development.

Atom Clojure Setup

This describes how I setup Atom for an ideal Clojure development workflow. This fixes indentation on newlines, handles parentheses, etc. The keybinding settings for enter (in keymap.cson) are important to get proper newlines with indentation at the right level. There are other helpers in init.coffee and keymap.cson that are useful for cutting, copying, pasting, deleting, and indenting Lisp expressions.

Install Atom

Download Atom

The Atom documentation is excellent. It's highly worth reading the flight manual.