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
(defvar my-swank-clojure-command "c:/path/to/swank-clojure.bat") | |
(defun my-start-swank-server () | |
(interactive) | |
(start-process "swank-clojure" " *swank-clojure*" my-swank-clojure-command)) |
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
(defadvice paredit-newline (around eval-print-last-sexp activate) | |
(if (eq major-mode 'lisp-interaction-mode) | |
(eval-print-last-sexp) | |
(paredit-newline))) |
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
(defadvice powershell (after process-coding-system activate) | |
(mapc #'(lambda (process) | |
(if (eq (process-buffer process) (current-buffer)) | |
(set-process-coding-system process 'sjis-dos 'sjis-dos))) | |
(process-list))) |
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 my-iterate [f x] | |
(cons x (lazy-seq (my-iterate f (f x))))) |
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
; trampolineを書けって問題だと思ったら違ったのね | |
; せっかくだから書いたtrampolineをメモしとこう | |
(defn my-trampoline [f & args] | |
((fn [f] (if (fn? f) (recur (f)) f)) (apply f args))) |
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
;; condotti's solution to Word Chains | |
;; https://4clojure.com/problem/82 | |
; この問題は結局グラフに開いたハミルトン路が含まれるかに帰着します。 | |
; 単語の順列を生成してしらみ潰しに調べればわかるのですが、効率が悪すぎるので、 | |
; 単語を頂点、1文字違いの単語の組を辺と考えて、辺の組み合わせを生成します。 | |
; 全ての辺を使ったグラフと頂点の数を変えずに、開いたオイラー路(一筆書き)が | |
; できれば、元のグラフにはハミルトン路が含まれることになります。元のグラフ | |
; から余計な辺を取り除くイメージですね。一筆書きは頂点の次数を求めれば判定 | |
; できます。多分しらみ潰しに調べるよりも多少は効率がいいはず。 |
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
(defcustom my-htmltopdf-program | |
"wkhtml2pdf" | |
"Program to convert html into pdf." | |
:type 'string | |
:group 'my) | |
(defcustom my-htmltopdf-args | |
"" | |
"command arguments for my-htmltopdf-program" | |
:type 'string |
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 brainfuck [s] | |
(letfn [(fmb [[t p] f ip] ; find matching bracket | |
((fn [ip n] | |
(condp = (nth s ip) | |
t (if (= n 0) ip (recur (f ip) (dec n))) | |
p (recur (f ip) (inc n)) | |
(recur (f ip) n))) | |
ip 0))] | |
((fn [c dp ip] | |
(if (< ip (count s)) |
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 brainfuck2 [s] | |
(let [c (transient (vec (repeat 30000 (byte 0))))] | |
(letfn [(fmb [[t p] f ip] ; find matching bracket | |
((fn [ip n] | |
(condp = (nth s ip) | |
t (if (= n 0) ip (recur (f ip) (dec n))) | |
p (recur (f ip) (inc n)) | |
(recur (f ip) n))) | |
ip 0))] | |
((fn [dp ip] |
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 combination [k xs] | |
(if (pos? k) | |
(if (<= (count xs) k) (list xs) | |
(concat | |
(map #(conj % (first xs)) (combination (dec k) (rest xs))) | |
(combination k (rest xs)))))) | |
(defn all-partitions [xs] | |
(map #(list % (seq (reduce disj (set xs) %))) | |
(combination (/ (count xs) 2) xs))) |
OlderNewer