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
(def size 50) | |
(def avalanche-threshold 3) | |
(def empty-table (vec (repeat size (vec (repeat size 0))))) | |
(defn adjacent-cells [x y] | |
(filter #(and (not (neg? (first %))) (not (neg? (second %))) (< (first %) size) (< (second %) size)) | |
(list [x (inc y)] [x (dec y)] [(inc x) y] [(dec x) y]))) | |
(defn avalanche [table cells-to-increment avalanches] |
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
(ns sandbox.fibo-dojo) | |
(def fib (cons 1 (cons 2 (lazy-seq (map + (rest fib) fib))))) | |
(def indexes (iterate inc 0)) | |
(defn cons-one? [xs prev] | |
(if (seq xs) | |
(if (and (= 1 prev) (= (first xs) prev)) true | |
(cons-one? (rest xs) (first xs))))) |
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
(ns sandbox.fibo-dojo) | |
(def fib (cons 1 (cons 2 (lazy-seq (map + (rest fib) fib))))) | |
(def indexes (iterate inc 0)) | |
(defn cons-one? [xs prev] | |
(if (seq xs) | |
(if (and (= 1 prev) (= (first xs) prev)) true | |
(recur (rest xs) (first xs))))) |
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
-module('shake'). | |
-import(lists,[reverse/1]). | |
-define(FILENAME,"/Users/maris/Documents/pg1000.txt"). | |
%% API exports | |
-compile(export_all). | |
insert(Children, [X | Xs]) -> | |
I = maps:get(X, Children, #{}), | |
maps:put(X, insert(I, Xs), Children); |
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
-module(dojo). | |
-import(lists,[nth/2,split/2,delete/2]). | |
-compile([export_all]). | |
deck() -> | |
[ {Rank, Suit} || Suit <- [hearts, spades, clubs, diamonds] , Rank <- [ace, king, queen, jack, 10, 9 ,8 ,7 , 6, 5 ,4 ,3 ,2] ]. | |
shuffle([]) -> | |
[]; | |
shuffle(Xs) -> |
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
(defun compile-run-tests (arg) | |
(interactive "P") | |
(let ((oldbuf (current-buffer))) | |
(save-buffer) | |
(nrepl-load-current-buffer) | |
(nrepl-switch-to-relevant-repl-buffer nil) | |
(insert "(run-specs)") | |
(nrepl-return) | |
(unless arg | |
(switch-to-buffer-other-window oldbuf)))) |
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
(defun eval-popup (arg) | |
(interactive "P") | |
(let* ((result (nrepl-eval (nrepl-last-expression))) | |
(val (plist-get result :value)) | |
(err (plist-get result :stderr))) | |
(pos-tip-show | |
(or val err)))) | |
(eval-after-load 'clojure-mode | |
'(define-key clojure-mode-map (kbd "\e\ee") 'eval-popup)) |
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
qsort([]) -> | |
[]; | |
qsort([H | T]) -> | |
L = [E || E <- T, E < H], | |
R = [E || E <- T, E > H], | |
P = [E || E <- T, E =:= H], | |
qsort(L) ++ [H | P] ++ qsort(R). |
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
!/usr/bin/env ruby | |
if ARGV.length < 4 | |
puts "Usage: enc-flac artist year album picture" | |
exit | |
end | |
artist = ARGV[0] | |
date = ARGV[1] | |
album = ARGV[2] |
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
!/usr/bin/env ruby | |
if ARGV.length < 4 | |
puts "Usage: enc-mp3 artist year album picture" | |
exit | |
end | |
artist = ARGV[0] | |
date = ARGV[1] | |
album = ARGV[2] |