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
(defn merge-keyed | |
"Returns a map that consists of the rest of the maps conj-ed onto | |
the first. If a key occurs in more than one map, the mapping(s) | |
from the latter (left-to-right) will be combined with the mapping in | |
the result by calling (f key val-in-result val-in-latter)." | |
[f & maps] | |
(when (some identity maps) | |
(let [merge-entry (fn [m e] | |
(let [k (key e) v (val e)] | |
(if (contains? m k) |
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 spec-context | |
(:require [clojure.spec :as s])) | |
(defmulti node-spec ::fancy?) | |
(defmethod node-spec true [_] ::fancy-node) | |
(defmethod node-spec :default [_] ::boring-node) | |
(s/def ::node (s/multi-spec node-spec ::fancy?)) | |
(s/def ::fancy? boolean?) |
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
(def ^:dynamic foo []) | |
(def ^:dynamic bar) | |
(defn state [] | |
{#'foo foo, #'bar bar}) | |
(defn helper [] | |
(uses bar) |
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
(let [n 5] | |
(js/eval | |
(iife | |
(let x 1) | |
(for [(let y 1) (<= y n) (++ y)] | |
(set! x (* x y))) | |
(return x) | |
))) |
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 ....... | |
:cljsbuild { | |
:builds [ | |
{:id "dev" | |
:source-paths ["src/"] | |
:compiler {:main "lev.client" | |
:asset-path "js" | |
:output-to "resources/public/js/lev.js" | |
:output-dir "resources/public/js"} |
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
"nREPL-worker-0" #14 daemon prio=5 os_prio=31 tid=0x00007fdec7d93800 nid=0x5703 runnable [0x000070000313c000] | |
java.lang.Thread.State: RUNNABLE | |
at clojure.lang.PersistentHashMap.valAt(PersistentHashMap.java:152) | |
at clojure.lang.PersistentHashMap.valAt(PersistentHashMap.java:156) | |
at clojure.lang.RT.get(RT.java:750) | |
at clojure.spec$map_spec_impl$reify__13776.conform_STAR_(spec.clj:782) | |
at clojure.spec$conform.invokeStatic(spec.clj:150) | |
at clojure.spec$dt.invokeStatic(spec.clj:731) | |
at clojure.spec$dt.invokeStatic(spec.clj:727) | |
at clojure.spec$merge_spec_impl$reify__13969$fn__13970.invoke(spec.clj:1140) |
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
{:user {:deploy-repositories [["clojars" {:url "https://clojars.org/repo" | |
:creds {:username "USERNAME" :password "PASSWORD"} | |
:sign-releases false}]]}} |
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
local thread = require 'thread' | |
local x = thread.variable(0) | |
print(x()) | |
x(5) | |
print(x()) | |
local itr = coroutine.wrap(function() | |
for i = 1, 10 do |
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
let Database = require('jseg').default; | |
let schema = require('./schema'); | |
class Builder { | |
constructor() { | |
this._jseg = new Database(schema); | |
this._roots = {}; | |
} |
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
// Consider a "relative" pointer to some offset within | |
// a buffer with some base address. | |
struct RelativePtr { | |
void* base; | |
int offset; | |
} | |
// Now consider some operation to compute the relative address: |