Skip to content

Instantly share code, notes, and snippets.

View svard's full-sized avatar

Kristofer Svärd svard

  • Stockholm, Sweden
View GitHub Profile
defmodule UniversalServer do
def universal_server() do
receive do
{:become, f} ->
f.()
end
end
def factorial_server() do
(defmodule universal-server
(export all))
(defun universal-server ()
(receive
((tuple 'become f)
(funcall f))))
(defun factorial-server ()
(receive
@svard
svard / .emacs
Last active April 1, 2016 17:00
My .emacs
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ansi-color-names-vector ["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"])
'(custom-enabled-themes (quote (deeper-blue))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
@svard
svard / redis-state
Created April 27, 2014 20:33
Trident redis state using marceline
;; Trident state persisted in redis.
;; Implemented in clojure using marceline lib.
;; Based on https://github.com/kstyrc/trident-redis
(ns state.redis
(:require [marceline.storm.trident :as t]
[clj-redis.client :as redis])
(:import [storm.trident.state.map CachedMap TransactionalMap NonTransactionalMap OpaqueMap SnapshottableMap]))
(defn- get-type-map
@svard
svard / BinarySearchTree
Last active August 29, 2015 13:58
Binary search tree in clojure
(ns tree.core
(:require [clojure.core.match :refer [match]]))
(defn get-max
[tree]
(match tree
nil nil
[nil x nil] x
[a x b] (recur b)))