Skip to content

Instantly share code, notes, and snippets.

Fogus fogus

Block or report user

Report or block fogus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View maze-generation
(require '[clojure.string :as s])
(defn north-of [[row col]] [(dec row) col])
(defn south-of [[row col]] [(inc row) col])
(defn west-of [[row col]] [row (dec col)])
(defn east-of [[row col]] [row (inc col)])
(defn neighbours [rows cols cell]
View mccarthy-eval.lisp
; John McCarthy, Artificial Intelligence Laboratory, Stanford University
; for CL : Rainer Joswig,
; this version runs in a Common Lisp
fogus / magic-the-gathering-card-spec.clj
Created Jul 13, 2018 — forked from robert-stuttaford/magic-the-gathering-card-spec.clj
Noodling around with core.spec, modelling M:tG card data
View magic-the-gathering-card-spec.clj
(ns magic-the-gathering-card-spec
(:require [clojure.spec :as s]
[clojure.spec.gen :as gen]))
(s/def ::pos-int (s/and int? (complement neg?)))
(s/def ::set string?)
(s/def ::set-number ::pos-int)
(s/def ::artist string?)
View MOP-COLA.adoc
fun send(rcv, msg, args) {
  cls = rcv.isa
  if (cls.isa == STD_CLS)
    method = builtin_lookup(rcv, msg)
    method = send(cls, "lookup", msg)
  method(rcv, args)
View units.clj
(ns party.units
(:refer-clojure :exclude [+ - * /])
(:require [clojure.algo.generic.arithmetic :as ari :use [+ - * /]]))
(defrecord Measurement [factor units]
(invoke [a b] (* a b)))
(defn ^:private short-name [sym]
(if (= (namespace sym) (namespace `foo))
fogus / service.clj
Last active Dec 1, 2017 — forked from mtnygard/service.clj
Using the not-found-interceptor as a catchall
View service.clj
(ns support.service
(:require [io.pedestal.http :as http]
[io.pedestal.http.route :as route]))
(defn about-page
{:status 200 :body (format "Clojure %s - served from %s"
(route/url-for ::about-page))})

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats. The link points back at them.

Why no pattern matching?

If you are talking about the aspect of pattern matching that acts as a conditional based upon structure, I'm not a big fan. I feel about them the way I do about switch statements - they're brittle and

View j.c
typedef char C;
typedef long I;
typedef struct a {
I t, r, d[3], p[2];
} *A;
#define P printf
#define R return
#define V1(f) A f(w)A w;
fogus /
Created Apr 24, 2017 — forked from BaseCase/
List of resources recommended or mentioned by the speakers at Deconstruct 2017

Deconstruct 2017 Bibliography

Here are all of the resources mentioned by Deconstruct 2017 speakers, along with who recommended what. Please post a comment if I missed something or have an error!

DC 2017 Speakers' Choice Gold Medalist

  • Seeing Like a State by James Scott


  • Public Opinion by Walter Lippmann (Evan Czaplicki)
  • A Pattern Language by Christopher Alexander (Brian Marick)
  • Domain Driven Design by Eric Evans (Brian Marick)
View evented-reader.cljs
(ns unrepl.evented-reader)
(defprotocol Closeable
(close [_]))
(defprotocol Stream
(read! [stream])
(unread! [stream])
(on-more [stream f]
"f is a function of two arguments: stream and an array where to push values.
You can’t perform that action at this time.