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 overmidi.core | |
(:use [overtone.live])) | |
(definst foo [note 60 vel 0.8] | |
(let [freq (midicps note)] | |
(* vel | |
(env-gen (perc 0.01 0.2) 1 1 0 1 :action FREE) | |
(+ (sin-osc (/ freq 2)) | |
(rlpf (saw freq) (* 1.1 freq) 0.4))))) ; => from overtone's wiki |
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
;; f1 | |
;; f2 f3 f4 | |
;; f5 | |
;; f6 | |
(def solved-cube | |
{:f1 [:w :w | |
:w :w] | |
:f2 [:o :o | |
:o :o] |
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
(get-in solved-cube [:f3 0]) | |
;; => :g | |
(assoc-in solved-cube [:f3 0] :w) | |
;; => a value identical to solved-cube except one sticker | |
;; changed from green to white (it's not a valid cube | |
;; layout any more). solved-cube is unaltered. | |
;; using the -> macro to 'thread' these together | |
(-> solved-cube |
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 face-cycle [c [q1 q2 q3 q4]] | |
(-> c | |
(assoc-in q2 (get-in c q1)) | |
(assoc-in q3 (get-in c q2)) | |
(assoc-in q4 (get-in c q3)) | |
(assoc-in q1 (get-in c q4)))) | |
(defn r [c] | |
(-> c | |
(face-cycle [[:f1 1] [:f6 1] [:f5 1] [:f3 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
(def r' (comp r r r)) | |
(def r2 (comp r 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
(def moves {:r r :r' r' :r2 r2 | |
:l l :l' l' :l2 l2 | |
:u u :u' u' :u2 u2 | |
:d d :d' d' :d2 d2 | |
:f f :f' f' :f2 f2 | |
:b b :b' b' :b2 b2}) | |
(def move-names (keys moves)) | |
(defn create-scramble [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
(let [moves (create-scramble 14) | |
scrambled-cube (reduce apply-named-move solved-cube moves)] | |
;; do something with the scrambled cube | |
) |
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 6) | |
(def rules {:be-born? #(contains? #{3} %) ;; high-life has this as #{3 6} | |
:stay-alive? #(contains? #{2 3} %)}) | |
(def glider #{[2 0] [0 1] [2 1] [1 2] [2 2]}) | |
(defn live? [xy gen] | |
(contains? gen xy)) |
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
line 21 sidesteps the fact that Math/abs doesn't work for clojure's Rational (ie fractional) datatype. |
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
while read f; do | |
date +"%H:%M:%S " | tr -d '\n'; | |
echo $f; | |
done |