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
(fn [s] | |
(vec (apply sorted-set (map vec (let [t (set (sort s)) | |
w (rest (butlast t)) | |
v (sort (if (empty? t) t (cons (first t) (conj (vec (map first | |
(remove | |
#(and (contains? (second %) 1) (contains? (second %) -1)) | |
(reduce #(assoc %1 %2 (set (map (partial - %2) t))) {} w)))) (last t)))))] | |
(if (empty? v) |
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
;; ariarule's solution to Generating k-combinations | |
;; https://4clojure.com/problem/103 | |
(fn [n z] | |
(set (filter #(= (count %) n) | |
(reduce (fn [seqs b] | |
(mapcat | |
(fn [s] (#(map (partial conj %) z) s)) seqs)) [#{}] (range n))))) |
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
(fn [f & s] | |
(let [result (apply f s)] | |
(if (fn? result) | |
(recur result ()) | |
result))) |
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
(fn mm [f s] | |
(lazy-seq | |
(let [fs (f (first s))] | |
(if (next s) | |
(cons fs (mm f (next s))) | |
(list fs))))) |
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 time-balance [schedule time-track excluded-items] | |
(- (time-until-the-end time-track) | |
(time-left-to-do schedule excluded-items))) |
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
;; ariarule's solution to Global take-while | |
;; https://4clojure.com/problem/114 | |
(fn [n p s] | |
(take (dec (count (take-while #(< % n) | |
(reduce #(let [n (if %2 | |
(inc (last %1)) | |
(last %))] | |
(conj %1 n)) | |
[0] |
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
///////////////////// | |
// SafetyGoggles | |
// @name SafetyGoggles | |
// @version 0.1.10082010 | |
// @description Highlighlights Weasel Words in Text. Just a proof of concept version. | |
// @include http://* | |
// THIS VERSION IS SLOW AND SOMETIMES BREAKS LINKS -- Still needs work | |
var docbod; | |
docbod = document.body; |