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 find-fn | |
[inputs outputs] | |
(doseq [x (ns-publics (the-ns `clojure.core))] | |
(try | |
(if (= outputs | |
(binding [*out* java.io.StringWriter] | |
(apply | |
(if (-> (second x) meta :macro) | |
(macroexpand `(second x)) | |
(second x)) |
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 find-fn | |
[in out] | |
(map first (filter | |
(fn [x] | |
(try | |
(= out | |
(binding [*out* java.io.StringWriter] | |
(apply | |
(if (-> (second x) meta :macro) | |
(macroexpand `(second x)) |
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
{:servers ["irc.freenode.net"] ; A list of servers. | |
:prepends #{"@"} ; The character you want for a prepend. Currently set to @ | |
:bitly-login "" ; Your bit.ly login. | |
:bitly-key "" ; API key and login above needed for URL shortening. | |
:wordnik-key "" ; API key needed for dictionary access. | |
:max-operations 3 ; The maximum number of operations that can be running at any given time. | |
:pending-ops 0 ; The number of operations running right now | |
:admin-add? true ; only admins can add help topics | |
:admin-rm? true ; only admins can remove help topics | |
:eval-prefixes {:defaults ["->" "." "," ; prefixes in any channel |
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 rotatel | |
([n col] | |
(let [n (mod n (count col))] | |
(concat | |
(drop n col) | |
(take n col)))) | |
([col] | |
(rotatel 1 col))) | |
(defn rotater |
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 bayes(a, b_given_a, b_given_not_a): | |
"""Calculates P(a|b) using bayes theorem. | |
Bayes theorem states that: | |
P(b|a) * P(a) | |
P(a|b) = -------------------------------- | |
P(b|a) * P(a) + P(b|~a) * P(~a) | |
Intuitively this is saying that the probability of b given a is equivalent |
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
function merge(array_one, array_two) | |
{ | |
var new_array_length = array_one.length + array_two.length; | |
var array_three = new Array(new_array_length); | |
var p_one = 0; | |
var p_two = 0; | |
for (var p_three = 0; p_three < new_array_length; p_three++) | |
{ | |
if (array_one.length == p_one) | |
{ |
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 fn-and | |
"Takes a set of functions and returns a fn which returns whether | |
every item in the juxtaposition of those functions is true." | |
([& fns] | |
(let [juxted-fns (apply juxt fns)] | |
(fn [& args] (every? true? (apply juxted-fns args)))))) |
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 C_yx [m1 m2 y x num-cols num-rows] | |
(reduce + | |
(map * | |
(map #(nth (nth m1 y) %1) (range num-cols)) | |
(map #(nth (nth m2 %1) x) (range num-rows))))) | |
(defn multiply [m1 m2] | |
(let [num-rows (count m1) num-cols (count (first m1))] | |
(for [y (range num-rows)] | |
(for [x (range num-cols)] |
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
(use 'clojure.contrib.math) | |
(def factorial | |
(fn [n] | |
(loop [cnt n acc 1] | |
(if (zero? cnt) | |
acc | |
(recur (dec cnt) (* acc cnt)))))) | |
(defn perm |
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
(defun input-question () | |
(print "Please enter a question which has a yes answer for your word. This question should result in a no for the incorrect word given earlier:") | |
(read-line)) | |
(defun input-chosen-word () | |
(print "Please enter the word that you chose at the start of the game:") | |
(read-line)) | |
(defun input-question-answer (question) | |
(print question) |
OlderNewer