This file contains hidden or 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 | |
| # my git difftool, calls FileMerge with project as -merge target | |
| # better than using opendiff | |
| # | |
| # cd to your project dir and and run difftool like this: | |
| # git difftool -d -x gdiff | |
| # find top level of git project | |
| dir=$PWD | |
| until [ -e "$dir/.git" ]; do |
This file contains hidden or 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 miner.bowling) | |
| ;; http://codingdojo.org/cgi-bin/index.pl?KataBowling | |
| ;; https://www.javacodegeeks.com/2016/05/bowling-kata-clojure-f-scala.html | |
| ;; game is a string, encoding balls rolled | |
| ;; X for strike | |
| ;; / for spare | |
| ;; - for a miss or gutter ball | |
| ;; 1-9 for that many pins |
This file contains hidden or 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 | |
| # launch a clojure plain repl but with options and classpath matching project.clj | |
| # Except when project.clj changes (and on first launch), lein is not called. | |
| if [ ! -f "project.clj" ]; then | |
| echo "No project.clj" | |
| exit 1 | |
| fi | |
| # stat (mostly) protects against staleness of copied project dir |
This file contains hidden or 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
| ;; map-alt is like the map xform but calls the funtions in an alternating order | |
| ;; (f i0) (g i1) (h i2) (f i3) ... | |
| ;; | |
| ;; In other words, map-alt spreads fn calls across elements, whereas (mapcat (juxt ...)) calls all | |
| ;; fns on each element. | |
| (defn map-alt | |
| ([] (map identity)) | |
| ([f] (map f)) |
This file contains hidden or 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 digits [n] | |
| {:pre [(int? n) (>= n 0)]} | |
| (loop [digs () remainder n] | |
| (if (< remainder 10) | |
| (conj digs remainder) | |
| (recur (conj digs (rem remainder 10)) (quot remainder 10))))) | |
| (defn digits+rev [n] | |
| (let [ds (digits n)] | |
| (concat ds (reverse ds)))) |
This file contains hidden or 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 miner.pal | |
| (:require [criterium.core :as crit] | |
| [clojure.string :as str])) | |
| ;; An exercise from Apropos Clojure #18 video cast: | |
| ;; https://www.youtube.com/watch?v=elF9BPa0Np4 | |
| ;; | |
| ;; Their solution is something like this... |
This file contains hidden or 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
| ;;; http://johnj.com/from-elegance-to-speed.html | |
| ;;; | |
| ;;; The author of the above blog post says that his `smt-8` was slow so he re-wrote it in | |
| ;;; Common Lisp and got nearly 300x improvement. I wrote some pure Clojure variations | |
| ;;; showing much improved performance over the original. | |
| ;;; | |
| ;;; Criterium for benchmarking: https://github.com/hugoduncan/criterium/ | |
| (ns miner.smt | |
| (:require [criterium.core :as cc])) |
OlderNewer