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 scratch.clomian | |
(:require clojure.java.io) | |
(:use [incanter core charts])) | |
;(set! *warn-on-reflection* true) | |
(def files (filter (fn [^java.io.File f] | |
(let [^String n (.getName f)] | |
(and | |
(.endsWith n ".dat") |
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
(defproject clj15 "0.1.0-SNAPSHOT" | |
:dependencies [[org.clojure/clojure "1.5.0-master-SNAPSHOT"]] | |
:repositories {"sonatype-oss-public" "https://oss.sonatype.org/content/groups/public/"} | |
) |
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
;; bin/repl with datomic-free-0.8.3664 | |
(use '[datomic.api :only [q db] :as d]) | |
(def uri "datomic:mem://future") | |
(d/create-database uri) | |
(def conn (d/connect uri)) | |
;; balance attr |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
;; 1. Common test utility | |
(require '[clojure.walk :as walk]) | |
(defmacro to-test [name & source] | |
`(defn ~(symbol (str name "-test")) [] ~@(for [case (filter list? source)] | |
`(assert ~(walk/postwalk-replace {'__ name} case))))) | |
;; 2. for each problem I write: | |
(def pNN | |
(fn ...solution here...)) |
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 adt | |
(:require [clojure.spec :as s])) | |
(defmacro match [spec x & cases] | |
(let [fr (s/form spec) | |
[ffr & frcases] fr | |
_ (assert (= `s/or ffr) | |
"match only works on clojure.spec/or specs") | |
expected-cases (set (take-nth 2 frcases)) | |
found-cases (set (map first cases)) |
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 net.thegeez.advent.spec-parsing | |
(:require [clojure.string :as str] | |
[clojure.spec :as s] | |
[clojure.spec.gen :as gen] | |
[clojure.test.check.generators :as tgen])) | |
;; Dependencies: | |
;; [org.clojure/clojure "1.9.0-alpha14"] | |
;; [org.clojure/test.check "0.9.0"] | |
;; Advent of Code is a series of code challenges in the form of an advent |
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 crepl.reagent.example | |
(:require [reagent.core :as r])) | |
(def temp-data (r/atom {:celsius 20 :fahrenheit 68})) | |
(defn calc-temperature [] | |
(let [{:keys [celsius fahrenheit] :as data} @temp-data] | |
(if (nil? celsius) | |
(assoc data :celsius (* (- fahrenheit 32) 5/9)) | |
(assoc data :fahrenheit (+ (* celsius 9/5) 32))))) |
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 crepl.tic-tac-toe | |
(:require [reagent.core :as r] | |
crepl.atom-sync)) | |
;; use this instead of reagent.core/atom to keep the state in sync | |
(def data (crepl.atom-sync/atom-sync {:turn :X})) | |
(def win-lines (-> #{} | |
(into (for [i (range 3)] | |
(for [j (range 3)] |
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 crepl.svg.smiley | |
(:require [reagent.core :as r] | |
crepl.atom-sync)) | |
(def happiness (crepl.atom-sync/atom-sync 30)) | |
(defn smiley [] | |
[:svg {:x 0 :y 0 :width 100 :height 100} | |
[:rect {:x 50 :y 50 :width 10 :height 10}] | |
[:circle {:cx 50 :cy 50 :r 40 :fill |