Skip to content

Instantly share code, notes, and snippets.

View claj's full-sized avatar

Linus Ericsson claj

  • Sweden
  • 03:47 (UTC +02:00)
View GitHub Profile
@claj
claj / core.clj
Last active March 17, 2016 10:38
state in go-loop
(ns world.core
(:require [clojure.core.async :refer [go chan >! <! <!! put! timeout close!]]))
(defn apply-to-fsm
[[state _] event]
(case [state event]
[:init :create] [:running [:allocate :run]]
[:running :stop] [:stopped [:stop]]
[:running :start] [:running []]
;; claj's solution to Reverse Interleave
;; https://4clojure.com/problem/43
(fn [a b] (map #(take-nth b (drop % a)) (range b)))
;; claj's solution to Set Intersection
;; https://4clojure.com/problem/81
(fn [a b] (set (filter a b)))
;; claj's solution to Anagram Finder
;; https://4clojure.com/problem/77
(fn [a]
(set
(map set
(filter #(< 1 (count %))
(vals
(group-by
(fn [b] (reduce conj #{} b))
@claj
claj / alephNoir.clj
Created October 3, 2011 06:37 — forked from ibdknox/alephNoir.clj
aleph and noir
(require '[noir.server :as server])
(use 'noir.core 'aleph.http 'lamina.core)
(defn async-response [response-channel request]
(enqueue response-channel
{:status 200
:headers {"content-type" "text/plain"}
:body "async response"}))
(defpage "/" [] "hey from Noir!")