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
1.9.3-p194 :002 > def foo | |
1.9.3-p194 :003?> require 'pry' | |
1.9.3-p194 :004?> Process.fork do | |
1.9.3-p194 :005 > binding.pry | |
1.9.3-p194 :006?> end | |
1.9.3-p194 :007?> Process.fork do | |
1.9.3-p194 :008 > binding.pry | |
1.9.3-p194 :009?> end | |
1.9.3-p194 :010?> end |
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
user=> [1 2 3 4 5] | |
[1 2 3 4 5] | |
user=> (map identity [1 2 3 4 5]) | |
(1 2 3 4 5) | |
user=> (conj [1 2 3 4 5] 6) | |
[1 2 3 4 5 6] | |
user=> (conj (map identity [1 2 3 4 5]) 6) | |
(6 1 2 3 4 5) |
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 increment-in-map [map key] | |
(update-in map [key] #(inc (or % 0)))) | |
(defn count-occurrences [to-count] | |
(loop [counted-so-far {} | |
remaining-to-count to-count] | |
(if (empty? remaining-to-count) | |
counted-so-far | |
(recur (increment-in-map counted-so-far (first remaining-to-count)) | |
(rest remaining-to-count))))) |
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
(with-open [rdr (io/reader "hello_goodbye.txt")] | |
(prn (frequencies (flatten (map seq (line-seq rdr)))))) | |
;{\h 3, \e 9, \l 6, \o 15, \g 6, \d 6, \b 6, \y 6} |
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
interface Quacker { | |
void Quack(); | |
} | |
class Duck implements Quacker{ | |
public void Quack(){ | |
System.out.println("quack"); | |
} | |
} |
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 a (lg/lvar 'a)) | |
(def b (lg/lvar 'b)) | |
(def lvars [a b]) | |
;simple attempt: | |
(lg/run* [q] | |
(fd/in a b (fd/interval 0 1)) | |
(lg/== q lvars)) | |
; this gives me the answer i want --> ([0 0] [0 1] [1 0] [1 1]) |
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 divides? [bottom top] | |
(zero? (mod top bottom))) | |
(def naturals (iterate inc 1)) | |
(defn multiples-of | |
([n] | |
(map #(* n %) (rest naturals))) | |
([n max] | |
(take-while #(<= % max) (multiples-of n)))) |
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 max-merge [first second] | |
(reduce | |
(fn [factors-so-far current-key] | |
(let [higher-value (max (get first current-key 0) (get second current-key 0))] | |
(assoc factors-so-far current-key higher-value))) | |
{} | |
(clojure.set/union (set (keys first)) (set (keys second))))) | |
(def naturals (iterate inc 1)) |
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 fun.graph) | |
(defn unvisited-neighbors [graph node path-so-far] | |
(clojure.set/difference | |
(get graph node) | |
(set path-so-far))) | |
(defn path-with-node [path new-node] | |
(conj path new-node)) |
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 hard-to-debug [& args] | |
(prn "this is a debug statement") | |
(if (not (empty? args)) | |
(prn (map (fn [_] (hard-to-debug)) (range 3))))) |