Skip to content

Instantly share code, notes, and snippets.

/* A simple state machine in C: The enemy moves left, then to the
* right, and finally stops. */
#include <stdio.h>
/* Enemy forward declaration, so that EnemyState can refer to it */
struct Enemy;
/* Enemy state type */
typedef struct EnemyState {
(defn fmap
"Filtering map. Like map, but removes nils from the result seq."
[& args]
(filter identity (apply map args)))
(defn update-matching
"Updates the given object(s) with fns selected by predicates.
(update-matching object(s) predicate-fn*)
(defn map-keys
"Applies f to all keys of m recursively."
[f m]
(cond
(map? m) (into {} (map (fn [[key value]]
[(f key) (map-keys f value)])
m))
(coll? m) (map (partial map-keys f) m)
:default m))
(defn maybe-reduce [f a l]
"Short-circuits if f returns nil."
(if (seq l)
(let [[b & cs] l
fab (f a b)]
(if cs
(if (nil? fab)
nil
(recur f fab cs))
fab))
(defn nil-or-last [[x & xs]]
(if xs
(if (nil? x)
nil
(recur xs))
x))
(use '[clojure.walk :only [prewalk-replace]])
(defmacro doto$
"Like doto, but replaces $ with a reference to the object."
[object & forms]
(let [object-sym (gensym "object")]
`(let [~object-sym ~object]
(doto ~object-sym
~@(prewalk-replace {'$ object-sym} forms)))))
;;; parenface.el --- Provide a face for parens in lisp modes.
;; By Dave Pearson <[email protected]>
;; $Revision: 1.1 $
;; Add a paren-face to emacs and add support for it to the various lisp modes.
;;
;; Based on some code that Boris Schaefer <[email protected]> posted
;; to comp.lang.scheme in message <[email protected]>.
(defvar paren-face 'paren-face)
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
(use '[clojure.contrib.map-utils
:only [deep-merge-with]])
(defn file-path [[first & rest]]
(if rest
{first (file-path rest)}
first))
(defn restore-hierarchy [x]
(->> x
# HG changeset patch
# Parent 9105afa7527a99de3620e61cb673416bac1da97b
Specify commit to check out instead of HEAD
diff -r 9105afa7527a PKGBUILD
--- a/PKGBUILD Thu Dec 08 17:38:09 2011 +0200
+++ b/PKGBUILD Thu Dec 08 17:48:11 2011 +0200
@@ -14,7 +14,7 @@
'66425a9e185788f720b466ca1caf5769')