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 memoize-async | |
"Returns a memoized version of a referentially transparent function. The | |
memoized version of the function keeps a cache of the mapping from arguments | |
to results and, when calls with the same arguments are repeated often, has | |
higher performance at the expense of higher memory use. | |
http://stackoverflow.com/questions/24698536/" | |
[f] | |
(let [mem (atom {})] | |
(fn [& args] | |
(go |
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 clojure-nen2580.core | |
(:require [thi.ng.geom.core :as g] | |
[thi.ng.geom.line :as l)) | |
(defn normal [l] | |
(let [[p q] (:points l)] | |
(g/normalize (g/- q p)))) | |
(defn continuous? [a b] | |
(let [na (normal a) |
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
;; -- clj macros | |
(defmacro defmodel | |
([name init [[state & args] & clauses]] | |
`(defmodel ~name | |
~(str "Reducing following messages into " name ": " | |
(clojure.string/join ", " (map first clauses))) | |
~init ([~state ~@args] ~@clauses))) | |
([name doc-string init [[state & args] & clauses]] | |
`(do |
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
import Color exposing (..) | |
import Graphics.Collage exposing (..) | |
import Graphics.Element exposing (..) | |
import Mouse | |
import Window | |
import Time | |
import Signal | |
main : Signal Element |
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
{:description "FIXME: write description", | |
:compile-path "/tmp/test/target/classes", | |
:deploy-repositories | |
[["clojars" | |
{:url "https://clojars.org/repo/", | |
:password :gpg, | |
:username :gpg}]], | |
:group "test", | |
:license | |
{:name "Eclipse Public License", |
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
float sdPlane(vec3 p, vec4 n) { | |
// n must be normalized | |
return dot(p, n.xyz) + n.w; | |
} | |
vec3 opTx(mat4 m, vec3 p) { | |
vec4 q = m * vec4(p, 1.0); | |
return q.xyz; | |
} |
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
// DEPTH | |
varying vec3 vViewPosition; | |
vertex: | |
attribute vec3 position; | |
uniform mat4 proj; | |
uniform mat4 view; |
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 nines.mesh | |
(:require [thi.ng.ndarray.core :as nd])) | |
(defprotocol Graph | |
(add-node [this x]) | |
(set-edge [this [u v] val]) | |
(get-edge [this [u v]]) | |
(del-edge [this [u v]]) | |
(neighbors [this 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
macro @ { | |
case { _ $x } => { | |
letstx $sx = [makeValue(unwrapSyntax(#{$x}), #{here})]; | |
return #{ Symbol.for($sx) } | |
} | |
} | |
function todoApp(state, action) { | |
if (state === undefined) state = initialState; | |
switch (action.type) { |
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
a = m.map(e => m.vector.apply(null, e), a_poly.vertices) | |
b = m.map(e => m.vector.apply(null, e), b_poly.vertices) | |
m.equals(m.set(a), | |
m.set(b)) | |
// you could cache the hash, so whenever and area (or polygon) is created/updated | |
// you would store the hash on it; inside the poly class (or Area) | |
v = m.map(e => m.vector.apply(null, e), this.vertices) |