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 sudoku | |
(:refer-clojure :exclude [==]) | |
(:use clojure.core.logic)) | |
(defn get-square [grid x y] | |
(for [x (range x (+ x 3)) | |
y (range y (+ y 3))] | |
(get-in grid [x y]))) | |
(defn init [grid [pos value]] |
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 distincto [s] | |
(if (seq s) | |
(all | |
(distinctfd (first s)) | |
(distincto (next s))) | |
s#)) | |
(defn all-infd [xs d] | |
(if (seq xs) | |
(all |
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 '[datomic.api :only [db q] :as d]) | |
(def schema | |
[{:db/doc "A persons name" | |
:db/id #db/id[:db.part/db] | |
:db/ident :name | |
:db/valueType :db.type/string | |
:db/cardinality :db.cardinality/one | |
:db.install/_attribute :db.part/db} | |
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 barker.client.main | |
(:require [barker.client.render :as render] | |
[barker.client.search :as search] | |
[shoreleave.client.common :as common] | |
[shoreleave.client.history :as history] | |
[shoreleave.client.pubsubs.simple :as pbus] | |
[shoreleave.client.pubsubs.protocols :as pubsub] | |
[shoreleave.client.worker :as swk] | |
) | |
(:use [jayq.core :only [$ attr]]) |
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 barker.client.search | |
(:require [clojure.string :as cstr] | |
[shoreleave.client.services.geo :as geo] | |
[shoreleave.client.remote :as remote]) | |
(:use [jayq.core :only [$ inner]])) | |
(defn query->map [search-query] | |
(let [[topic location] (map cstr/trim (cstr/split search-query #" near ")) | |
zip (when (re-find #"\d" location) location)] ;if we see an digit, we assume it's some kind of zip | |
{:raw-query search-query :topic topic :location location :zip zip})) |
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
(defmacro with | |
"do things with the first expression passed, | |
and produce the result" | |
[expr & body] | |
`(let [~'% ~expr] ~@body)) | |
(defmacro within | |
"do things with the first expression passed (for side effects), | |
but produce the value of the first expression" | |
[expr & body] |
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 automath | |
"Namespace of functions that are proxies for methods on | |
java.lang.Math for maximum developer convenience." | |
(:use [clojure.string :only (lower-case)])) | |
(def ^{:private true | |
:doc "Set of method names not to generate a proxy function for."} | |
exclusions #{"min" "max"}) | |
(defn- methods-in |
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
/* The whole point of the twIP stack is to respond to pings. This is | |
done by reading one IP packet at a time, hoping that it is an IP | |
ping packet (no check is made!), changing the packet type to a ping | |
reply packet, updating the ICMP checksum, swapping the IP source | |
and destination addresses, and sending the packet back. That's | |
it. | |
*/ | |
/* This is the packet buffer. I chose the size of the array so that | |
the maximum packet size that twIP would support would be the same |
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.core.match :only [match]]) | |
(defn evaluate [env exp] | |
(match [exp] | |
[(['Number a] :seq)] a | |
[(['Add x y] :seq)] (+ (evaluate env x) (evaluate env y)) | |
[(['Multiply x y] :seq)] (* (evaluate env x) (evaluate env y)) | |
[(['Variable i] :seq)] (env i))) | |
(def environment {"a" 3, "b" 4, "c" 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
(def users [{:name "Brian" :age 22} {:name "Ben" :age 19}]) | |
;; Takes a "path", returns a function that takes an "object" and | |
;; returns a "costate" | |
(defn lens [p] | |
(fn [o] | |
{:get (get-in o p) | |
:set #(assoc-in o p %1)})) | |
(def myAgeLens (lens [0 :age])) |