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 queue | |
[& c] | |
(into | |
(clojure.lang.PersistentQueue/EMPTY) | |
c)) | |
(defn k-combos | |
[k r] | |
(if (zero? k) nil | |
(letfn |
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
;; problem representation | |
;; {:L 5 | |
;; :S { 0 #{1 2} | |
;; 1 #{1 5 3} | |
;; 2 #{2 3} }} | |
(defn combos | |
[n s] | |
(letfn | |
[(expand |
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 clj-bunnies.simpleabm) | |
(def SIZE 5) | |
(def HISTORY 3) | |
(def EAT-RATE 1) | |
(def METABOLIC-RATE 0.3) | |
(def MOVE-RANGE 1) | |
(defn grass | |
[s] |
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 bench.ptest | |
(:import (java.util.concurrent Executors))) | |
(defn run [num-threads] | |
"Create a vector of atoms of size size. Create a thread-pool | |
of size num-threads. Each thread will iterate (1) selecting | |
ten random atoms from the vector and then (2) reset!ing the | |
lowest valued atom with the value of the highest. Each thread | |
has its own java.util.Random." | |
(let [size 1000000 |
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
(def ctl #{" > "}) | |
(defn interpret [[regs branch] [op arg1 arg2 arg3]] | |
;(println op arg1 arg2 arg3 regs branch) | |
(if branch | |
(if (contains? ctl op) | |
(case op | |
" > " (if (> (regs arg1)(regs arg2)) | |
[regs (not branch)] | |
[regs branch])) |
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 rand-inst [] | |
(let [ops '("add" "sub" "mul" "div" "cpy" " > ") | |
regs '(0 1 2 3)] | |
(list (rand-nth ops) (rand-nth regs) | |
(rand-nth regs) | |
(rand-nth regs)))) | |
(defn gen-rand [size] | |
(for [n (range 0 size)] | |
(rand-inst))) |
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 execute [prog regs] | |
(first (reduce interpret [regs true] prog))) |
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 rand-seqn [prog size seed] | |
(loop [ i 0 | |
seqn [seed]] | |
(if (>= i size) | |
seqn | |
(recur (inc i) | |
(conj seqn (first | |
(execute prog [(last seqn) 1.0 1.0 1.0]))))))) | |
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
""" | |
blog - randomcomputation.blogspot.com | |
(c) - jccc | |
""" | |
""" | |
We provide a tutorial on register machine induction and investigat | |
e the nature of various heuristic assumptions on learning performa | |
nce. |