This file contains hidden or 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 remove-first [pred coll] | |
(let [[xs ys] (split-with (complement pred) coll)] | |
(concat xs (rest ys)))) | |
(definterface FirstRemover | |
(^clojure.lang.LazySeq removeFirst [coll])) | |
(definterface FirstRemoverFactory | |
(^user.FirstRemover makeRemover [pred])) |
This file contains hidden or 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 remove-first | |
[pred coll] | |
(apply concat ((juxt take-while (comp rest drop-while)) (complement pred) coll))) | |
(remove-first (partial = 3) [1 2 3 1 2 3]) | |
;;; (1 2 1 2 3) | |
(remove-first even? [1 2 3 1 2 3]) | |
;;; (1 3 1 2 3) |
This file contains hidden or 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
;; An exercise in writing #'rest without [0-9a-zA-Z], by Tim McCormack | |
;; Note that the input must be a vector, although the code could easily be | |
;; modified to vector-ify any input coll. | |
;; Let's take this a step at a time... | |
(#(((% 1) :main) %) ;; call the main method with the input and fns | |
[[0 1 2 3 4 5] ;; the input is hardcoded here | |
;; fns are accessed by static indices into the fn table | |
{:main #(if (= (% 0) []) |
This file contains hidden or 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
;; It all started here: http://clojure-log.n01se.net/date/2011-04-06.html#19:04 | |
(#((% (+(*))) %) ;; call arg 1 with all args | |
[;; data | |
(+ (*)(*)(*)(*)(*)(*)(*)) | |
;; main fn -- simulate 'if' with map lookup and closures | |
#(({(+) (% (+(*)(*)))} ;; if zero return 'then' clause | |
(% (+)) ;; dispatch on first arg | |
(% (+(*)(*)(*)))) ;; call 'else' clause (n not found in map) | |
%) |
This file contains hidden or 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
import SimpleOpenNI.*; | |
import processing.opengl.*; | |
SimpleOpenNI kinect; | |
boolean running = false; | |
boolean devinMode = false; | |
boolean debug = true; |