Skip to content

Instantly share code, notes, and snippets.

@tranchis
tranchis / ordered_combination.clj
Created October 7, 2015 14:21
A Clojure function to obtain a lazy sequence with all the elements from an arbitrary amount of (potentially lazy!) input sequences ordered by a given function
(ns ordered-combination)
(defn ordered-combination
[sort-fn seqs]
(if (every? empty? seqs)
'()
(let [sorted (sort-by #(sort-fn (first %)) seqs)
chosen (first sorted)
new-seqs (concat [(rest chosen)] (rest sorted))]
(concat [(first chosen)]
@tranchis
tranchis / pom2proj.clj
Last active February 25, 2018 06:02 — forked from thickey/pom2proj.clj
Fixed some NPE when fields are not set in pom.xml
(ns pom2proj
(:require [clojure.xml :as xml]
[clojure.zip :as zip]
[clojure.java.io :as io]
[clojure.data.zip.xml :as zx])
(:use [clojure.pprint :only [pprint]]))
(defn- text-attrs
[loc ks]
(map (fn [k]